'“react must be in scope” error while creating React project
I am new to React.JS, I created a new project using react command
npx create-react-app but after creating the project I received an error:
'react' must be in scope when using jsx react/react-in-jsx-scope
Solution 1:[1]
Version > React 17.
This is an ESLint rule that can be disabled in your .eslintrc or .eslintrc.json file. In older versions of React each file had to have import React from "react" as an import, however in newer versions of React (since React 17) this is no longer required. This rule made sure (in older versions) that it was imported so there'd be no unseen errors, however now you clearly still have this rule enabled somehow.
Try adding "react/react-in-jsx-scope": 0, under the rules section of your .eslintrc/.eslintrc.json file.
Version < React 17.
You need to add import React from "react" to the top of your file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ben Rauzi |
