Skip to content
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

Nextjs SSR prints warning on useLayoutEffect #4

Open
ichn-hu opened this issue Oct 26, 2021 · 1 comment · May be fixed by #5
Open

Nextjs SSR prints warning on useLayoutEffect #4

ichn-hu opened this issue Oct 26, 2021 · 1 comment · May be fixed by #5

Comments

@ichn-hu
Copy link

ichn-hu commented Oct 26, 2021

If we use the react component in SSR, the following warning will be generated

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://reactjs.org/link/uselayouteffect-ssr for common fixes.
    at ReactCusdis (/home/ichn/Documents/notion-blog-v2/node_modules/react-cusdis/dist/ReactCusdis.js:7:26)
    at div
    at RenderPost (/home/ichn/Documents/notion-blog-v2/.next/server/pages/blog/[slug].js:2970:3)
    at MyApp (/home/ichn/Documents/notion-blog-v2/.next/server/pages/_app.js:37:3)
    at AppContainer (/home/ichn/Documents/notion-blog-v2/node_modules/next/dist/server/render.js:293:29)
@arekgotfryd
Copy link

Same here

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://reactjs.org/link/uselayouteffect-ssr for common fixes.
    at ReactCusdis (E:\nextjs-blog\node_modules\react-cusdis\dist\ReactCusdis.js:7:26)
    at footer
    at main
    at div
    at Layout (webpack-internal:///./components/layout.tsx:26:19)
    at Post (webpack-internal:///./pages/posts/[id].tsx:25:17)
    at App (webpack-internal:///./pages/_app.tsx:11:16)
    at InnerApp
    at StyleRegistry (E:\nextjs-blog\node_modules\styled-jsx\dist\stylesheet-registry.js:231:34)
    at AppContainer (E:\nextjs-blog\node_modules\next\dist\server\render.js:340:29)
    at AppContainerWithIsomorphicFiberStructure (E:\nextjs-blog\node_modules\next\dist\server\render.js:370:57)
    at div
    at Body (E:\nextjs-blog\node_modules\next\dist\server\render.js:638:21)

@ichn-hu ichn-hu linked a pull request Dec 20, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants