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.

500 Error can not use getInitialProps with getStaticProps after updated react 18, next 12

See original GitHub issue

What version of Next.js are you using?

12.0.4

What version of Node.js are you using?

16.13.0

What browser are you using?

chrome

What operating system are you using?

macOS

How are you deploying your application?

next dev

Describe the Bug

I updated react to version 0.0.0-experimental-149b420f6-20211119 (I heard it as a newest experimantal version, 18) due to use a suspense for my project. (I don’t have a plan to use a server component).

So I followed all the steps React 18 And also I updated next to v12

But I couldn’t get a beta version through npm install next@latest react@beta react-dom@beta so I tried like this way npm install react@beta react-dom@beta --save --legacy-peer-deps

And I added a

module.exports = {
  experimental: {
    concurrentFeatures: true
  }
}

Eventually I encountered all this error in every page. Error: You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps / in main page, Error: 'getInitialProps' in Document component is not supported with 'concurrentFeatures' enabled. in another pages. I don’t use any getInitialProps in my project.

Expected Behavior

I think there could be some error in downloading a react 18 I mentioned.

To Reproduce

image image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
chentsulincommented, Nov 30, 2021

I can reproduce this error by using the official example:

npx create-next-app@latest -e custom-server-express custom-server

With the following settings:

next.config.js -

module.exports = {
  experimental: {
    concurrentFeatures: true,
  },
}

dependencies -

    "next": "12.0.5-canary.11",
    "react": "^18.0.0-beta-0cc724c77-20211125",
    "react-dom": "^18.0.0-beta-0cc724c77-20211125"

Then, execute npm run dev:

截圖 2021-11-30 下午2 38 49

image

1reaction
huozhicommented, Nov 30, 2021

👍 Thanks for the reproduction. Can you try next v12.0.5-canary.12 to see if it resolves your issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Error Handling - Next.js
Having a 500 page in your application does not show specific errors to the app user. You can also use 404 page to...
Read more >
Fetch data from an API on the server-side with ... - Egghead.io
In this lesson, we will learn how to use getServerSideProps to dynamically fetch data and server-side render pages by consuming a "user profile"...
Read more >
getstaticprops not passing props - You.com | The AI Search ...
i had same problem for use getStaticProps. my problem solved with this way. you can create a lib folder in project root. and...
Read more >
Build a blog with Next (React.js) and Strapi
First, you must create a function to fetch data from your Strapi API. Create a ./frontend/lib/api.js file containing the following code:.
Read more >
500 Internal Server Error, using Next.js Causing Refresh ...
We are encountering a http status 500 issue for all of our sites and we can't make out why this is happening. Running...
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