Simran Mhaske
Simran Mhaske

Reputation: 65

I am getting an error saying 'BrowserRouter' is not defined react/jsx-no-undef

This is the following code which is giving an error Is is that I am importing BrowserRouter incorrectly or something? Can someone please help me figure this out?

    import React from 'react';
    import ReactDOM from 'react-dom';
    import './index.css';
    import App from './App';
    import * as serviceWorker from './serviceWorker';

    ReactDOM.render(
      <BrowserRouter>
      <App />
      </BrowserRouter>,
      document.getElementById('root')
    );
    serviceWorker.unregister();

Upvotes: 0

Views: 2401

Answers (1)

Kevin Hoopes
Kevin Hoopes

Reputation: 507

Yes, you are not currently importing BrowserRouter at all. You will need to add this line to your import statements.

import { BrowserRouter } from 'react-router-dom' 

You'll also need to install the react-router-dom dependency if you haven't done that.

Upvotes: 5

Related Questions