-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next.js error on first load #76
Comments
Chakra handles that with a cookie docs here even next-theme has some issues like that https://github.com/pacocoursey/next-themes#useTheme a common trick is to check if the component is mounted before rendering const [isMounted, setIsMounted] = useState(false)
useEffect(() => {
setIsMounted(true)
}, [])
if (isMounted) // use the preferred color schema value I was testing in a nextjs project when introduced this issue but the specific component was not server rendered 🤦♂️ |
in my opinion a solution for that is not in the scope of this project :) |
really helpful stuff. thanks, @greg-schrammel |
From the version v1.1.3, users may get the following error:
This happens because after the version v1.1.2, the first client render will return the users preffered color scheme, but on the server side render it will return
no-preference
, thus causing this mismatch from the content if it depends on the response from the hook.I personally do not use Next.js nor other SSR framework, and I am not really sure how to handle such error. If anyone has an anwser please contribute!
The text was updated successfully, but these errors were encountered: