J
J
jamster2021-01-07 11:57:19
JavaScript
jamster, 2021-01-07 11:57:19

How to fix router Invariant failed error in React?

Error in react.
Help please.

5ff6ccda7d73d620671489.png

import React from "react";
import ReactDOM from "react-dom";
import "./index.scss";
import { App } from "./App";
import * as serviceWorker from "./serviceWorker";
import { BrowserRouter, Router, Switch, Route } from "react-router-dom";
import { createBrowserHistory } from "history";
import { ReactRouterGlobalHistory } from "./components";

const history = createBrowserHistory();

ReactDOM.render(
  <BrowserRouter>
    <React.StrictMode>
      <Router history={history}>
        <ReactRouterGlobalHistory />
        <Switch>
          <Route path="/" component={App} />
        </Switch>
      </Router>
    </React.StrictMode>
  </BrowserRouter>,

  document.getElementById("root"),
);


// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();


Happy holiday everyone!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question