2

Making a test project with React on debian 10 with VScode on Windows 8.1, when using the command yarn start in project folder, then an error comes out:

./src/App.js
  Line 6:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 7:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 8:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 9:    'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 10:  'React' must be in scope when using JSX  react/react-in-jsx-scope
  Line 12:   'React' must be in scope when using JSX  react/react-in-jsx-scope

solutions with import React from 'react'; or "react/react-in-jsx-scope": "off" is didnt work. What else could be the problem?

3
  • 1
    import React from 'react'; should absolutely get rid of this error. (Which I assume occurs because you're using React 16 or earlier.) Please show us your App.js including this import, and what error you get when running that (assuming it's different from the above, which it certainly should be). Commented Jun 10, 2022 at 21:47
  • Maybe I am missing somthing, or maybe your using WSL. But I don't get how your creating a React program in Debian on windows 8.1 (it has to be WSL right?) if so you should state that, if not, please clarify. Commented Jun 13, 2022 at 21:03
  • @J-D3V I'm not sure if it is because you are using WSL. I am using windows and still getting the same error (React 18.0.2). And I have no idea why. Commented Nov 18, 2022 at 16:23

2 Answers 2

3
  1. Added in the beginning part of js file.

import React from 'react'

This will resolve the problem

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
problem solved i just updated yarn and nodeJS
0

I was having the same issue, it got solved by running npm audit fix --force. I would try reinstalling the packages.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.