react/create-react-app

[v4] Bug: React 17, React is not defined after ejecting

Open

#9,953 创建于 2020年10月29日

在 GitHub 查看
 (20 评论) (4 反应) (0 负责人)JavaScript (103,386 star) (27,059 fork)batch import
contributions: up for grabs!good first issueissue: bugissue: needs investigation

描述

React version: 17.0.1

Steps To Reproduce

  1. npx create-react-app my-app
  2. cd my-app
  3. npm start (Works like a charm)
  4. npm run eject
  5. npm i
  6. npm start (ReferenceError: React is not defined)

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.

贡献者指南