React-router-dom errror: `You should not use <Route> or withRouter() outside a <Router>`

102 views Asked by At

I'm getting the You should not use <Route> or with Router() outside a <Router> error, but I'm already calling the route inside the router. There is my index.js:

import { BrowserRouter as Router, Route } from "react-router-dom";
import App from "./components/App";

const Wrapper = () => (
  <Router>
    <Route path="/:view?/" render={(props) => <App {...props} />} />
  </Router>
);

ReactDOM.render(<Wrapper />, document.getElementById("root"));

Every route is inside App and therefore wrapped by the Router. Does anyone have any idea why it could be happening here?

Thank you for your help,

1

There are 1 answers

0
Caio Davi On

I found out what was happening. MDBReact Pro doesn't support the latest version of react-router-dom (what is kinda strange because their free version works well with it). I had to downgrade react-router-dom to version 4.3.1. Thank you, Shlang, for the hint. It helped me to figure out what was happening