skip to Main Content

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?

2

Answers


    1. Added in the beginning part of js file.

    import React from ‘react’

    This will resolve the problem

    Login or Signup to reply.
  1. I was having the same issue, it got solved by running npm audit fix –force.
    I would try reinstalling the packages.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search