useLayoutEffect does nothing on the server
See original GitHub issuewindmill-react-ui
version: 0.1.0-alpha.8
Relevant code or config:
import React from 'react'
import '../css/tailwind.css'
import { Windmill } from 'windmill-react-ui'
function MyApp({ Component, pageProps }) {
return (
<Windmill>
<Component {...pageProps} />
</Windmill>
)
}
export default MyApp
What you did:
Rendered Windmill
component with NextJS
What 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)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to fix the "Warning: useLayoutEffect does nothing on the ...
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useLayoutEffect does nothing on the server · Issue #6 - GitHub
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useLayoutEffect and SSR - Medium
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useLayoutEffect and the warning on SSR - Eight Bites
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
RenderWhere
workaround re-renders the whole page after hydration. Form element loose their state in this case so this is not ideal.@estevanmaito would you consider using
useBrowserLayoutEffect
?It avoids the warning for SSR:
Example usage: https://github.com/dhovart/next10-intl/blob/4638d3dc91eee4a7f35b8d056c74fdf126ea9f85/src/context/Next10IntlProvider.tsx Similar use in Redux: https://github.com/reduxjs/react-redux/blob/d16262582b2eeb62c05313fca3eb59dc0b395955/src/components/connectAdvanced.js#L40
This was a workaround to get things going on
nextjs
components/render-where.tsx
pages/_app.tsx