-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v4] Bug: React 17, React is not defined after ejecting #9953
Comments
I guess that this issue should be moved to https://github.com/facebook/create-react-app |
This is not an issue about create-react-app. Thanks for replying quickly. |
I'm having this exact issue even without ejecting. I followed the migration guide, ran react-codemod, deleted node_modules. The compiler says the code compiled successfully but getting the red screen in the browser. |
Upgrade React 17 and remove the CRA ejection issue has been fixed in #9885 and needs to wait for the maintainer to publish a new version. :) |
use npm create-react-app my-app |
I followed the steps here to reproduce the error. But everything works fine. This means the issue isn't with create-react-app |
Can't reproduce the error here either. Second that Steps to Reproduce, step 5 is done automatically. |
npm i and npm install is the same thing tho |
Hi, I want to work on this issue, can you please assign it to me |
Hi, I checked the code and tried to reproduce the scenario but it didn't give any error so went and checked the code provided in the first post. https://codesandbox.io/s/ecstatic-wood-ou6px?file=/src/index.js So, the problem here is when you remove the react imports then you need to de-structure and then import the react functions as an object. `import React from "react"; import App from "./App"; const rootElement = document.getElementById("root"); So, after you remove the react import statement then you have to remove the React. syntax from the code else the JSX compiler will not read the react code. `import {StrictMode} from "react"; import App from "./App"; const rootElement = document.getElementById("root"); |
In simple Terms, console.log(React); All the confusion is because React has said there's no need to import React library but we need to import everything besides import React. |
Is this issue solved? |
is this issue solved? |
I tried all the mentioned steps and everything is working fine with my code. Sample Code
Not necessary to import react object just import the strictmode from react and everything works fine. |
React version: 17.0.1
Steps To Reproduce
Link to code example: https://codesandbox.io/s/ecstatic-wood-ou6px
The current behavior
I upgraded react to 17 and removed "import React"s from my project files (except index.js where react mounted). But I got "ReferenceError: React is not defined" in those files.
To investigate the issue behind this, I created a new react app, the new JSX transformation was working. But when I eject, it throws the same errors.
So;
Without react-scripts, new JSX transformation doesn't working.
The expected behavior
Components should render without declaring React (import React from "react") if React is in scope.
The text was updated successfully, but these errors were encountered: