React Hydration Issue #45
Answered
by
lochie
jethroguce
asked this question in
Q&A
-
How do you solve this ?
here's problematic code: const Header = () => {
const {signedIn} = useSiwe()
return (
<div>...
{
signedIn ?
(
<Link href="/dashboard" passHref legacyBehavior>
<Nav.Link>Dashboard</Nav.Link>
</Link>
) :
(
<Link href="/#about" passHref legacyBehavior>
<Nav.Link>About</Nav.Link>
</Link>
)
}...
</div>
)
} |
Beta Was this translation helpful? Give feedback.
Answered by
lochie
Nov 15, 2022
Replies: 2 comments
-
I guess connectkit doesn't have ssr support |
Beta Was this translation helpful? Give feedback.
0 replies
-
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! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lochie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
Hope that helps!