500 Error can not use getInitialProps with getStaticProps after updated react 18, next 12
See original GitHub issueWhat 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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (8 by maintainers)
Top GitHub Comments
I can reproduce this error by using the official example:
With the following settings:
next.config.js -
dependencies -
Then, execute
npm run dev
:👍 Thanks for the reproduction. Can you try next v12.0.5-canary.12 to see if it resolves your issue?