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;
6
  • What version of react-router-dom are you using ? You can look inside your package.json. Commented Dec 7, 2021 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. Commented Dec 7, 2021 at 21:39
  • @yousoumar I am on the latest version 17.0.2 Commented Dec 7, 2021 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? Commented Dec 7, 2021 at 23:48
  • Does this answer your question? 'React' must be in scope when using JSX react/react-in-jsx-scope? Commented Oct 23, 2022 at 22:02

1 Answer 1

0

3 solutions:

  1. I have fixed this issue after running this command.

    npm install react-scripts@latest

  2. if not fixed try to delete node_modules

    then run npm install

  3. npm install react@latest react-dom@latest

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

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.