NextJS getServerSideProps causes ant-design's FormItemLabel component to crash
See original GitHub issueReproduction link
https://github.com/fasfoxcom/pnpm-next-antd
Steps to reproduce
- Make sure
getServerSideProps
is present on the page - Install dependencies
pnpm install
- Run
pnpm build
- Run
pnpm start
- Access the page at http://localhost:3000/
- Crash
The culprit is this bit of code down here:
export async function getServerSideProps() {
return {
props: {},
};
}
Removing getServerSideProps
stops the crashing
What is expected?
We should be able to build and run our Next app without a crash when getServerSideProps
is present
What is actually happening?
When we run pnpm start
and attempt to access the page after building the project successfully with pnpm build
we get a crash and the following error following error:
TypeError: Cannot read properties of undefined (reading 'vertical')
at Object.children (/.../pnpm-antd-next-bug/node_modules/.pnpm/antd@4.20.4_sfoxds7t5ydpegc3knd667wn6m/node_modules/antd/lib/form/FormItemLabel.js:88:26)
at a.b.render (/.../pnpm-antd-next-bug/node_modules/.pnpm/react-dom@17.0.2_react@17.0.2/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:213)
at a.b.read (/.../pnpm-antd-next-bug/node_modules/.pnpm/react-dom@17.0.2_react@17.0.2/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
at Object.exports.renderToString (/.../pnpm-antd-next-bug/node_modules/.pnpm/react-dom@17.0.2_react@17.0.2/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
at Object.renderPage (/.../pnpm-antd-next-bug/node_modules/.pnpm/next@12.1.6_sfoxds7t5ydpegc3knd667wn6m/node_modules/next/dist/server/render.js:804:45)
at Object.defaultGetInitialProps (/.../pnpm-antd-next-bug/node_modules/.pnpm/next@12.1.6_sfoxds7t5ydpegc3knd667wn6m/node_modules/next/dist/server/render.js:391:51)
at Function.getInitialProps (/.../pnpm-antd-next-bug/.next/server/pages/_document.js:607:20)
at Object.loadGetInitialProps (/.../pnpm-antd-next-bug/node_modules/.pnpm/next@12.1.6_sfoxds7t5ydpegc3knd667wn6m/node_modules/next/dist/shared/lib/utils.js:65:29)
at documentInitialProps (/.../pnpm-antd-next-bug/node_modules/.pnpm/next@12.1.6_sfoxds7t5ydpegc3knd667wn6m/node_modules/next/dist/server/render.js:817:48)
at renderDocument (/.../pnpm-antd-next-bug/node_modules/.pnpm/next@12.1.6_sfoxds7t5ydpegc3knd667wn6m/node_modules/next/dist/server/render.js:841:55)
Environment | Info |
---|---|
antd | 4.20.4 |
React | 17.0.2 |
System | Mac OS Version 12.3.1 |
Browser | Chrome Version 101.0.4951.54 (Official Build) (arm64) |
Note that running pnpm dev
does not crash when accessing the app.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
NEXTJS: getServerSideProps not working into components
Create a getServerSideProps function on the component. // @components/MyComponent.tsx import { GetServerSidePropsContext } from 'next'; function ...
Read more >How to use Ant Design with Next.js - LogRocket Blog
Integrate Ant Design, an enterprise UI design philosophy for React applications, and Next.js, to build apps more efficiently.
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
If anyone encounters this issue, our diagnostic was wrong. This has nothing to do with PNPM, this is an incompatibility in Next 12.1.6 which got upgraded when we changed our package manager. Downgrading to Next 12.1.5 fixes it, and it also seems to be fixed in 12.1.7-canary.
Leaving out the
label
prop fromForm.Item
also prevents the crash from happening when accessing the page.