-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Bug] Warning: useLayoutEffect does nothing on the server #381
Comments
We certainly don't want to trigger these warnings when rendering on the server, but I'm trying to figure out what would be the best way to do that. The suggested solution ( In case of our Map component which is triggering the warning, I have two thoughts:
|
Having the same issue For a temporary fix where do I put that code?
I am using Remix so I guess it's rendering something server side Error message:
|
I've seen this recommended several times, mostly related to unit-testing, but you could give this a shot: Somewhere in the code that exclusively runs on the server (no Idea how that works with remix, sorry), you could add this code that disables the
Let me know if that works. |
For Remix, I don't have much experience with Remix either, but maybe you can use the client module setting to avoid server rendering if you haven't tried it yet. Server vs. Client Code Execution | Remix - https://remix.run/docs/en/main/discussion/server-vs-client#splitting-up-client-and-server-code |
Description
After installing the react-google-maps package we started getting the following error:
In our own project we used something like this to prevent this warning issue.
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect
This means that it will use useLayoutEffect normally, but during Server Side Rendering it will use useEffect
Steps to Reproduce
Use react-google-maps inside of a NextJS project.
Environment
Logs
The text was updated successfully, but these errors were encountered: