question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Warning: useLayoutEffect does nothing on the server" appeared since updating to @latest version.

See original GitHub issue

*If reverting @apollo/client to @3.3.14, warning disappears I’m extensively using the getStaticProps method by nextJS in my application and everything was running smoothly, but once I did an update of all the packages, I started seeing this annoying warning. I reverted to a previous commit and updated packages one by one, thinking it was a material-ui problem. But the warning appeared only after updating @apollo/client.

Intended outcome: Updating packages, from 3.3.14 to @3.3.16.

Actual outcome: This is the warning I started getting after the update: Screenshot 2021-05-04 at 09 54 05

And I noticed mismatches started appearing in the console. This is a rehydration problem probably, but it wasn’t there before updating… example mismatch: Screenshot 2021-05-04 at 14 38 43

My package.json file: Screenshot 2021-05-04 at 09 54 33

My Apollo Initialization (from zeit/nextjs apollo example) (The APOLLO_STATE_PROP_NAME variable is just a string = “APOLLO_STATE”): Screenshot 2021-05-04 at 09 55 50

Versions Run the following command in your project directory, and paste its (automatically copied to clipboard) results here:

npx envinfo@latest --preset apollo --clipboard:

Screenshot 2021-05-04 at 09 59 24

All the additional packages are not used, I’m only using @apollo/client at the moment.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
benjamncommented, May 4, 2021

@zakariamofaddel Thanks for reporting this! Assigning to @brainkim since this looks like a consequence of #8022.

1reaction
brainkimcommented, May 4, 2021

@zakariamofaddel I’m doing some testing and it feels as though the only reason the new useLayoutEffect()-backed useReactiveVar() might be causing client/server mismatches is because you’re calling the reactive var during rendering, which is a React no-no. Of course, I could be wrong about this, but that means that even if we squelch the useLayoutEffect warnings, you might continue to have client/server mismatch errors. We’ll try to have a fix which squashes the warnings soon, but in the meantime, 1. can you make sure you’re not calling reactive variables in the render function? and 2. can you create a small reproduction for the client/server mismatch if this isn’t the case?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: useLayoutEffect does nothing on the server ... - GitHub
Gives "Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format." Steps to reproduce....
Read more >
How to fix this warning "useLayoutEffect" related warning?
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will ...
Read more >
useLayoutEffect and SSR - Medium
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >
React useLayoutEffect vs. useEffect with examples
React will always flush a previous render's effects before starting a new update. Now, how does this differ from the useLayoutEffect Hook?
Read more >
Hooks API Reference - React
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. This page...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found