-
Notifications
You must be signed in to change notification settings - Fork 151
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
useLayoutEffect does nothing on the server #3
Comments
Need to dig a little more into this, but:
Will keep it open to remind me. |
Hi! what is the solution for |
@ronyfhebrian Please, refer to the comment above yours. It's a warning and it's needed to render the component only on client. |
A mismatch in server rendered UI and client side UI is a potential dealbreaker for us folks using Styled JSX but since wrapping the app in the Not ideal, we're out here in the tailwind v2 and React 17 world. Still a handy UI library though. Appreciate your work! |
This was a workaround to get things going on
|
The @estevanmaito would you consider using It avoids the warning for SSR: const useBrowserLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : () => {} Example usage: https://github.com/dhovart/next10-intl/blob/4638d3dc91eee4a7f35b8d056c74fdf126ea9f85/src/context/Next10IntlProvider.tsx |
This comment works for me. https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85#gistcomment-3886909 Just put this in
useLayoutEffect and useEffect have the same argument signature, and neither runs if we're not in a browser. |
windmill-react-ui
version:0.1.0-alpha.8
Relevant code or config:
What you did:
Rendered
Windmill
component with NextJSWhat happened:
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://fb.me/react-uselayouteffect-ssr for common fixes.
Reproduction:
Docs repo of this project (not available yet)
The text was updated successfully, but these errors were encountered: