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.

React-select 4.2.0 and NextJS ends up in document not defined

See original GitHub issue

After 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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:11

github_iconTop GitHub Comments

3reactions
ebonowcommented, Mar 5, 2021

@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.

2reactions
stefcameroncommented, Mar 5, 2021

@ebonow Thank you for the quick turn around, much appreciated! Our builds are successful once again with 4.2.1. 🎉

Read more comments on GitHub >

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

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