Next.js should not automatically expose the `React` global
See original GitHub issueBug report
Describe the bug
When you use JSX in your app, we automatically expose the React
global. This allows things like React.useState
to work even though it’s not imported.
To Reproduce
Use React.useState
in your app without an import, and see it work.
Expected behavior
It should not work, and instead, require React be imported.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Migrating from Create React App - Next.js
Migrating from Create React App. This guide will help you understand how to transition from an existing non-ejected Create React App project to...
Read more >Basic Features: Environment Variables - Next.js
By default environment variables are only available in the Node.js environment, meaning they won't be exposed to the browser. ... This loads process.env....
Read more >next.config.js: Environment Variables
Learn to add and access environment variables in your Next.js application at build time.
Read more >next.config.js: Runtime Configuration
To add runtime configuration to your app, open next.config.js and add the publicRuntimeConfig and serverRuntimeConfig configs:
Read more >CDN Support with Asset Prefix - next.config.js
Attention: Deploying to Vercel automatically configures a global CDN for your ... Do not upload the rest of your .next/ folder, as you...
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
It would not
Only when React is used it should be imported. Using JSX is fine without importing:
When doing a
useState
however it’s non-standard that this currently works:It should be written as:
Considering this fixed when you upgrade to React 17.