2

I am getting this error,

3:9 error 'React' must be in scope when using JSX react/react-in-jsx-scope

I have read and searched on multiple sites, to include React on the top. Now that i have added, but still getting the error. Any help will be much appreciated, I am in the Learning phase, got stuck!

import React from 'react';
import { Route } from  'react-router-dom';

import AllMeetupsPage from "./pages/AllMeetups";
import Favorites from "./pages/Favorites";
import NewMeetup from "./pages/NewMeetups";

function App() {
  return (
    <div>
      <Route path="/">
        <AllMeetupsPage></AllMeetupsPage>
      </Route>
      <Route path="/new-meetup">
        <NewMeetup></NewMeetup>
      </Route>
      <Route path="/favorites">
        <Favorites></Favorites>
      </Route>
    </div>
  );
}

export default App;
Drew Reese
  • 165,259
  • 14
  • 153
  • 181
  • What version of `react-router-dom` are you using ? You can look inside your `package.json`. – Youssouf Oumar Dec 07 '21 at 21:31
  • 1
    What version of `react` are you using? In your project's directory run `npm list react react-dom`. React versions *before* 17 require `React` to be declared and in scope in each file rendering JSX, v17 and later do not. – Drew Reese Dec 07 '21 at 21:39
  • @yousoumar I am on the latest version 17.0.2 – arbab umair Dec 07 '21 at 23:27
  • If you are on React v17+ then you shouldn't need to import `React` to have it in scope. Have you stopped/killed/restarted any code watchers/hot reloaders? – Drew Reese Dec 07 '21 at 23:48
  • Does this answer your question? ['React' must be in scope when using JSX react/react-in-jsx-scope?](https://stackoverflow.com/questions/42640636/react-must-be-in-scope-when-using-jsx-react-react-in-jsx-scope) – Henry Woody Oct 23 '22 at 22:02
  • I am using react@18.2.0 with react-native@0.71.11 and I have to have the `import React from 'react';` to stop eslint giving that warning. – Will Jun 17 '23 at 08:20

0 Answers0