Home > Enterprise >  getting error 'React' must be in scope when using JSX react/react-in-jsx-scope
getting error 'React' must be in scope when using JSX react/react-in-jsx-scope

Time:07-11

the code is as follows i am getting error

" React' must be in scope when using JSX react/react-in-jsx-scope" ***

import {BrowserRouter as  Router, Routes, Route} from 'react-router-dom';
    
    function App() {
      return (
        <>
        <Router>
        <Navbar/>
        <Routes>
          <Route path= '/' exact />
          </Routes>
        </Router>
         
        </>
      );
    }
    
    export default App;

CodePudding user response:

Error came because you did not import React.

import react from 'react';

This import is required under React 17 And no more required since React 17

CodePudding user response:

Since you haven't provided the full code here, I assume that your React import statement is wrong. Import React on top of your .js file

import React from 'react';
  • Related