Select mode="multiple" throws useLayoutEffect warning in Next.js
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
Reproduce locally
npx create-next-app nextjs-antd-select-bug
cd nextjs-antd-select-bug
npm install antd
npm run dev
Edit pages/index.js
import {Select} from "antd";
import "antd/dist/antd.css";
export default function Page() {
return (
<div>
<Select
mode="multiple"
style={{width: "300px"}}
>
<Select.Option value="A">Option A</Select.Option>
<Select.Option value="B">Option B</Select.Option>
</Select>
</div>
)
}
Open http://localhost:3000/ The warning is logged in the server console with every page refresh
Reproduce on Codesandbox
- Open https://codesandbox.io/s/awesome-moser-wr83y
- Hit Refresh button in the Browser panel
- The warning is logged in the Terminal log
What is expected?
No exceptions or warnings are expected.
What is actually happening?
The following warning is logged upon every single page refresh.
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. Toavoid this, useLayoutEffect should only be used in components that renderexclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
at Overflow (/sandbox/node_modules/rc-overflow/lib/Overflow.js:35:32)
at SelectSelector (/sandbox/node_modules/rc-select/lib/Selector/MultipleSelector.js:36:18)
at div
at Selector (/sandbox/node_modules/rc-select/lib/Selector/index.js:36:35)
at Trigger (/sandbox/node_modules/rc-trigger/lib/index.js:79:36)
at SelectTrigger (/sandbox/node_modules/rc-select/lib/SelectTrigger.js:66:25)
at div
at Select (/sandbox/node_modules/rc-select/lib/generate.js:88:34)
at Select (/sandbox/node_modules/rc-select/lib/Select.js:95:34)
at InternalSelect (/sandbox/node_modules/antd/lib/select/index.js:55:31)
at div
at Page
at App (webpack-internal:///./node_modules/next/dist/pages/_app.js:31:1)
at AppContainer (/sandbox/node_modules/next/dist/next-server/server/render.js:28:859)
Environment | Info |
---|---|
antd | 4.15.4 |
React | 17.0.2 |
System | macOS Big Sur 11.3 |
Browser | Safari 14.1 |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:50
- Comments:61 (8 by maintainers)
Top Results From Across the Web
usePreventScroll causes useLayoutEffect warning in Nextjs
I'm learning Next.js and I'm trying to integrate the @react-aria/overlays package in my project. I have a layout component, where I'm simply ...
Read more >react-component - Bountysource
Warning : useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead...
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 >Change Log - Ant Design
Fix Space throws Encountered two children with the same key warning in some cases. #35311. Fix Select tag remove icon position issue.
Read more >Next.jsにAnt Designを導入する方法 - Qiita
まず次のコマンドを使ってNext.jsプロジェクトを作ります: ... Select mode="multiple" throws useLayoutEffect warning in Next.js · Issue #30396 ...
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
I’m getting the same issue with the
Menu
component also triggering thisrc-overflow
behaviour:Affects version 4.16.0; 4.15.6 doesn’t have this issue.
+1 Menu also has this problem. version: 4.16.0 Downgrading to 4.15.6 fixs the problem.