question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NextJS getServerSideProps causes ant-design's FormItemLabel component to crash

See original GitHub issue

Reproduction link

https://github.com/fasfoxcom/pnpm-next-antd

Steps to reproduce

  1. Make sure getServerSideProps is present on the page
  2. Install dependencies pnpm install
  3. Run pnpm build
  4. Run pnpm start
  5. Access the page at http://localhost:3000/
  6. 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:closed
  • Created a year ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
lerelacommented, May 16, 2022

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.

1reaction
lerelacommented, May 12, 2022

Leaving out the label prop from Form.Item also prevents the crash from happening when accessing the page.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found