Skip to content

React Hydration Issue #45

Answered by lochie
jethroguce asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @jethroguce, you may need to set up an isMounted check to avoid hydration issues in Next.js.

Easiest way to do this is to put something like this at the top of your component before rendering:

const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) return null;
return ... // render your component

Hope that helps!

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lochie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants