react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Tutorial: Tic-Tac-Toe Running Locally results in compile error

Open adamdoescode opened this issue 2 years ago • 3 comments
trafficstars

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

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

adamdoescode avatar Feb 11 '23 07:02 adamdoescode

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

adamdoescode avatar Feb 28 '23 01:02 adamdoescode

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])

spasche avatar Mar 02 '23 13:03 spasche

I just setup the tutorial and adding import React from 'react' was sufficient to get the application running correctly

RossellaFer avatar Mar 14 '23 21:03 RossellaFer

Hey ,Can I work on this issue? :)

sambhavgupta0705 avatar Mar 22 '23 06:03 sambhavgupta0705

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.

camechi avatar May 10 '23 09:05 camechi

Hey guys this is unfortunately a known issue with a workaround. Let's continue coordination here: https://github.com/reactjs/react.dev/issues/6317

lunaleaps avatar Oct 19 '23 20:10 lunaleaps