react.dev
react.dev copied to clipboard
Tutorial: Tic-Tac-Toe Running Locally results in compile error
Bug
Attempting to run the starter project for the tic-tac-toe tutorial results in a compile error because App.js does not have an import statement for the React library.
Solution
Add import React from 'react' to the top of the App.js file.
Steps to reproduce
- On the react tic-tac-toe tutorial page, follow the instructions to download this minimal sandbox.
- Make a new folder, unzip the sandbox zip file into it.
- run
npm installto install packages - run
npm run
This will return the following error:
Failed to compile.
./src/App.js
Line 5: 'React' must be in scope when using JSX react/react-in-jsx-scope
Search for the keywords to learn more about each error.
Thanks, Adam
Hi,
So I had to setup this tutorial again and encountered the same problem. Turns out adding import React from 'react' to the top of the App.js file is not sufficient.
Instead, it is nessecary to find all package.json files within the react-app and change references to packages chokidar and fsevents that refer to old packages so they point to the latest package.
Cheers, Adam
An alternative is to update create-react-app dependency by following instructions on https://github.com/facebook/create-react-app/blob/main/CHANGELOG.md (e.g. npm install --save --save-exact [email protected])
I just setup the tutorial and adding import React from 'react' was sufficient to get the application running correctly
Hey ,Can I work on this issue? :)
I got my local setup of this tutorial running by running npx create-react-app nameOfApp , and creating the files as is necessary in the directories.
Hey guys this is unfortunately a known issue with a workaround. Let's continue coordination here: https://github.com/reactjs/react.dev/issues/6317