React-select 4.2.0 and NextJS ends up in document not defined
See original GitHub issueAfter updating from 4.1.0 to 4.2.0 my NextJS app does not start anymore throwing the error below.
It seems to be an issue with the usage of document and ssr. Document usually cannot be used within the server side since undefined. Fallback to 4.1.0 resolves the issue.
error - ReferenceError: document is not defined
at Object.<anonymous> (/node_modules/react-select/dist/index-1793e281.cjs.dev.js:359:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/node_modules/react-select/dist/Select-59696ec1.cjs.dev.js:4:13)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/node_modules/react-select/dist/react-select.cjs.dev.js:5:29)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:11
Top Results From Across the Web
Next.js: document is not defined - Stack Overflow
I think, in server rendering mode, the document is undefined. You should be able to use it inside class lifecycle methods or useEffect...
Read more >Solve “document is not defined” errors in Next.js | by WebTutPro
The “React” way to solve this issue would be to use the useEffect React hook. Which only runs at the rendering phase, so...
Read more >ConfigProvider - Ant Design
This component provides a configuration to all React components underneath itself via the context API. In the render tree all components will have...
Read more >uncaught error: could not find react-redux context value
I wanted to integrate redux with my react project but faced Uncaught Error: could not find react-redux context value; please ensure the component...
Read more >Gatsby Changelog | 5.3.0
Gatsby Head also automatically places your meta tags into the generated HTML so you also no longer need a Gatsby plugin in your...
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
@mercteil , @joakim-roos , @jhonnyizidoro , @stefcameron
We have released a patch for version 4.2.1. Please kindly take a look and verify that this resolves your issues.
@ebonow Thank you for the quick turn around, much appreciated! Our builds are successful once again with 4.2.1. 🎉