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

请问能否修复下 useLayoutEffect 在 SSR 下报错的问题? #532

Closed
moecasts opened this issue Feb 4, 2021 · 0 comments · Fixed by #533
Closed

请问能否修复下 useLayoutEffect 在 SSR 下报错的问题? #532

moecasts opened this issue Feb 4, 2021 · 0 comments · Fixed by #533

Comments

@moecasts
Copy link
Contributor

moecasts commented Feb 4, 2021

例如 locale 插件,在开启 SSR 模式时,会报如下错误。

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 _LocaleContainer (/var/www/umi/dist/umi.server.js:208307:72)
at module.exports../src/.umi/plugin-model/Provider.tsx.webpack_exports.default (/var/www/umi/dist/umi.server.js:208690:3)
[SSR] render /23fdd196841768a25512.hot-update.json start: 743.42ms

参考修复方法如下,
facebook/react#14927 (comment)

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.

1 participant