react BrowserRouter resulting in “You should not use or withRouter() outside a ”












2















I am hitting this problem constantly, and have been stuck at it for a long time now. I am new to mbdreact library and I have been trying this example of theirs from this link. This has given me too many problems in debugging and understanding what is going on.



Problem :



You should not use <Route> or withRouter() outside a <Router>


The detailed error trace I could pull is as follows :



Uncaught Error: You should not use <Route> or withRouter() outside a <Router>
at invariant (browser.js:34)
at Route.computeMatch (Route.js:96)
at new Route (Route.js:72)
at constructClassInstance (react-dom.development.js:13082)
at updateClassComponent (react-dom.development.js:14978)
at beginWork (react-dom.development.js:15845)
at performUnitOfWork (react-dom.development.js:18879)
at workLoop (react-dom.development.js:18920)
at HTMLUnknownElement.callCallback (react-dom.development.js:147)
at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
at invokeGuardedCallback (react-dom.development.js:250)
at replayUnitOfWork (react-dom.development.js:18127)
at renderRoot (react-dom.development.js:19038)
at performWorkOnRoot (react-dom.development.js:19941)
at performWork (react-dom.development.js:19851)
at performSyncWork (react-dom.development.js:19825)
at requestWork (react-dom.development.js:19680)
at scheduleWork (react-dom.development.js:19487)
at scheduleRootUpdate (react-dom.development.js:20191)
at updateContainerAtExpirationTime (react-dom.development.js:20217)
at updateContainer (react-dom.development.js:20285)
at ReactRoot.push../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render (react-dom.development.js:20564)
at react-dom.development.js:20718
at unbatchedUpdates (react-dom.development.js:20068)
at legacyRenderSubtreeIntoContainer (react-dom.development.js:20714)
at Object.render (react-dom.development.js:20781)
at Module../src/index.js (index.js:10)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Object.0 (index.js:15)
at __webpack_require__ (bootstrap:782)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1


Code :



package.json



{
"name": "test",
"version": "0.0.1",
"private": true,
"dependencies": {
"@material-ui/core": "^3.7.1",
"axios": "^0.18.0",
"classnames": "^2.2.6",
"contentful": "^7.0.5",
"jquery": "^3.3.1",
"mdbreact": "^4.8.6",
"prop-types": "^15.6.2",
"react": "^16.7.0-alpha.2",
"react-dom": "^16.7.0-alpha.2",
"react-router-dom": "^4.4.0-beta.6",
"react-scripts": "2.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}


index.js



import React from 'react';
import ReactDOM from 'react-dom';
import 'font-awesome/css/font-awesome.min.css';
import 'bootstrap-css-only/css/bootstrap.min.css';
import 'mdbreact/dist/css/mdb.css';
import './index.css';
import App from './App';
//import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, 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.
//serviceWorker.unregister();


App.js



import React from 'react'
import { MDBContainer } from 'mdbreact';

import FixedNavbarExample from './components/navbar/NavbarPage'



const App = () => {

return (
<div>
<FixedNavbarExample/>
<MDBContainer style={{height: 100}} className="text-center mt-5 pt-5">
</MDBContainer>
</div>
)
}

export default App


NavbarPage.js



import React from 'react';
import { MDBContainer, MDBNavbar, MDBNavbarBrand, MDBNavbarNav, MDBNavbarToggler, MDBCollapse, MDBNavItem, MDBNavLink, MDBIcon } from 'mdbreact';
import { BrowserRouter as Router } from 'react-router-dom';

class FixedNavbarExample extends React.Component {
constructor(props) {
super(props);
this.state = {
collapse: false,
};
this.onClick = this.onClick.bind(this);
}

onClick() {
this.setState({
collapse: !this.state.collapse,
});
}

render() {
const bgPink = {backgroundColor: '#e91e63'}
const container = {height: 1300}
return(
<div>
<Router>
<header>
<MDBNavbar style={bgPink} dark expand="md" scrolling fixed="top">
<MDBNavbarBrand href="/">
<strong>Navbar</strong>
</MDBNavbarBrand>
<MDBNavbarToggler onClick={ this.onClick } />
<MDBCollapse isOpen = { this.state.collapse } navbar>
<MDBNavbarNav left>
<MDBNavItem active>
<MDBNavLink to="#">Home</MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="#">Features</MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="#">Pricing</MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="#">Options</MDBNavLink>
</MDBNavItem>
</MDBNavbarNav>
<MDBNavbarNav right>
<MDBNavItem>
<MDBNavLink to="#"><MDBIcon icon="facebook" /></MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="#"><MDBIcon icon="twitter" /></MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="#"><MDBIcon icon="instagram" /></MDBNavLink>
</MDBNavItem>
</MDBNavbarNav>
</MDBCollapse>
</MDBNavbar>
</header>
</Router>
</div>
);
}
}

export default FixedNavbarExample;


What I have found so far :





  • I have referenced the following StackOverflow posts




    • link1


    • link2




  • from what I am seeing the problem is in the NavbarPage.js. The articles above tell me 2 things : (First-Thing) to wrap all of the content in <div> which the example link from mdbreact tutorial is already doing & (Second-Thing) to move inside which is also done.


  • I have also tried renaming the import from BrowserRouter as Router to just BrowserRouter, and made corresponding refactoring. Even that resulted in the same error.



Looking for help in understanding what is causing this problem, to further my understanding in react, mdbreact.










share|improve this question



























    2















    I am hitting this problem constantly, and have been stuck at it for a long time now. I am new to mbdreact library and I have been trying this example of theirs from this link. This has given me too many problems in debugging and understanding what is going on.



    Problem :



    You should not use <Route> or withRouter() outside a <Router>


    The detailed error trace I could pull is as follows :



    Uncaught Error: You should not use <Route> or withRouter() outside a <Router>
    at invariant (browser.js:34)
    at Route.computeMatch (Route.js:96)
    at new Route (Route.js:72)
    at constructClassInstance (react-dom.development.js:13082)
    at updateClassComponent (react-dom.development.js:14978)
    at beginWork (react-dom.development.js:15845)
    at performUnitOfWork (react-dom.development.js:18879)
    at workLoop (react-dom.development.js:18920)
    at HTMLUnknownElement.callCallback (react-dom.development.js:147)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
    at invokeGuardedCallback (react-dom.development.js:250)
    at replayUnitOfWork (react-dom.development.js:18127)
    at renderRoot (react-dom.development.js:19038)
    at performWorkOnRoot (react-dom.development.js:19941)
    at performWork (react-dom.development.js:19851)
    at performSyncWork (react-dom.development.js:19825)
    at requestWork (react-dom.development.js:19680)
    at scheduleWork (react-dom.development.js:19487)
    at scheduleRootUpdate (react-dom.development.js:20191)
    at updateContainerAtExpirationTime (react-dom.development.js:20217)
    at updateContainer (react-dom.development.js:20285)
    at ReactRoot.push../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render (react-dom.development.js:20564)
    at react-dom.development.js:20718
    at unbatchedUpdates (react-dom.development.js:20068)
    at legacyRenderSubtreeIntoContainer (react-dom.development.js:20714)
    at Object.render (react-dom.development.js:20781)
    at Module../src/index.js (index.js:10)
    at __webpack_require__ (bootstrap:782)
    at fn (bootstrap:150)
    at Object.0 (index.js:15)
    at __webpack_require__ (bootstrap:782)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1


    Code :



    package.json



    {
    "name": "test",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
    "@material-ui/core": "^3.7.1",
    "axios": "^0.18.0",
    "classnames": "^2.2.6",
    "contentful": "^7.0.5",
    "jquery": "^3.3.1",
    "mdbreact": "^4.8.6",
    "prop-types": "^15.6.2",
    "react": "^16.7.0-alpha.2",
    "react-dom": "^16.7.0-alpha.2",
    "react-router-dom": "^4.4.0-beta.6",
    "react-scripts": "2.1.2"
    },
    "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
    },
    "eslintConfig": {
    "extends": "react-app"
    },
    "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
    ]
    }


    index.js



    import React from 'react';
    import ReactDOM from 'react-dom';
    import 'font-awesome/css/font-awesome.min.css';
    import 'bootstrap-css-only/css/bootstrap.min.css';
    import 'mdbreact/dist/css/mdb.css';
    import './index.css';
    import App from './App';
    //import * as serviceWorker from './serviceWorker';

    ReactDOM.render(<App />, 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.
    //serviceWorker.unregister();


    App.js



    import React from 'react'
    import { MDBContainer } from 'mdbreact';

    import FixedNavbarExample from './components/navbar/NavbarPage'



    const App = () => {

    return (
    <div>
    <FixedNavbarExample/>
    <MDBContainer style={{height: 100}} className="text-center mt-5 pt-5">
    </MDBContainer>
    </div>
    )
    }

    export default App


    NavbarPage.js



    import React from 'react';
    import { MDBContainer, MDBNavbar, MDBNavbarBrand, MDBNavbarNav, MDBNavbarToggler, MDBCollapse, MDBNavItem, MDBNavLink, MDBIcon } from 'mdbreact';
    import { BrowserRouter as Router } from 'react-router-dom';

    class FixedNavbarExample extends React.Component {
    constructor(props) {
    super(props);
    this.state = {
    collapse: false,
    };
    this.onClick = this.onClick.bind(this);
    }

    onClick() {
    this.setState({
    collapse: !this.state.collapse,
    });
    }

    render() {
    const bgPink = {backgroundColor: '#e91e63'}
    const container = {height: 1300}
    return(
    <div>
    <Router>
    <header>
    <MDBNavbar style={bgPink} dark expand="md" scrolling fixed="top">
    <MDBNavbarBrand href="/">
    <strong>Navbar</strong>
    </MDBNavbarBrand>
    <MDBNavbarToggler onClick={ this.onClick } />
    <MDBCollapse isOpen = { this.state.collapse } navbar>
    <MDBNavbarNav left>
    <MDBNavItem active>
    <MDBNavLink to="#">Home</MDBNavLink>
    </MDBNavItem>
    <MDBNavItem>
    <MDBNavLink to="#">Features</MDBNavLink>
    </MDBNavItem>
    <MDBNavItem>
    <MDBNavLink to="#">Pricing</MDBNavLink>
    </MDBNavItem>
    <MDBNavItem>
    <MDBNavLink to="#">Options</MDBNavLink>
    </MDBNavItem>
    </MDBNavbarNav>
    <MDBNavbarNav right>
    <MDBNavItem>
    <MDBNavLink to="#"><MDBIcon icon="facebook" /></MDBNavLink>
    </MDBNavItem>
    <MDBNavItem>
    <MDBNavLink to="#"><MDBIcon icon="twitter" /></MDBNavLink>
    </MDBNavItem>
    <MDBNavItem>
    <MDBNavLink to="#"><MDBIcon icon="instagram" /></MDBNavLink>
    </MDBNavItem>
    </MDBNavbarNav>
    </MDBCollapse>
    </MDBNavbar>
    </header>
    </Router>
    </div>
    );
    }
    }

    export default FixedNavbarExample;


    What I have found so far :





    • I have referenced the following StackOverflow posts




      • link1


      • link2




    • from what I am seeing the problem is in the NavbarPage.js. The articles above tell me 2 things : (First-Thing) to wrap all of the content in <div> which the example link from mdbreact tutorial is already doing & (Second-Thing) to move inside which is also done.


    • I have also tried renaming the import from BrowserRouter as Router to just BrowserRouter, and made corresponding refactoring. Even that resulted in the same error.



    Looking for help in understanding what is causing this problem, to further my understanding in react, mdbreact.










    share|improve this question

























      2












      2








      2


      1






      I am hitting this problem constantly, and have been stuck at it for a long time now. I am new to mbdreact library and I have been trying this example of theirs from this link. This has given me too many problems in debugging and understanding what is going on.



      Problem :



      You should not use <Route> or withRouter() outside a <Router>


      The detailed error trace I could pull is as follows :



      Uncaught Error: You should not use <Route> or withRouter() outside a <Router>
      at invariant (browser.js:34)
      at Route.computeMatch (Route.js:96)
      at new Route (Route.js:72)
      at constructClassInstance (react-dom.development.js:13082)
      at updateClassComponent (react-dom.development.js:14978)
      at beginWork (react-dom.development.js:15845)
      at performUnitOfWork (react-dom.development.js:18879)
      at workLoop (react-dom.development.js:18920)
      at HTMLUnknownElement.callCallback (react-dom.development.js:147)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
      at invokeGuardedCallback (react-dom.development.js:250)
      at replayUnitOfWork (react-dom.development.js:18127)
      at renderRoot (react-dom.development.js:19038)
      at performWorkOnRoot (react-dom.development.js:19941)
      at performWork (react-dom.development.js:19851)
      at performSyncWork (react-dom.development.js:19825)
      at requestWork (react-dom.development.js:19680)
      at scheduleWork (react-dom.development.js:19487)
      at scheduleRootUpdate (react-dom.development.js:20191)
      at updateContainerAtExpirationTime (react-dom.development.js:20217)
      at updateContainer (react-dom.development.js:20285)
      at ReactRoot.push../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render (react-dom.development.js:20564)
      at react-dom.development.js:20718
      at unbatchedUpdates (react-dom.development.js:20068)
      at legacyRenderSubtreeIntoContainer (react-dom.development.js:20714)
      at Object.render (react-dom.development.js:20781)
      at Module../src/index.js (index.js:10)
      at __webpack_require__ (bootstrap:782)
      at fn (bootstrap:150)
      at Object.0 (index.js:15)
      at __webpack_require__ (bootstrap:782)
      at checkDeferredModules (bootstrap:45)
      at Array.webpackJsonpCallback [as push] (bootstrap:32)
      at main.chunk.js:1


      Code :



      package.json



      {
      "name": "test",
      "version": "0.0.1",
      "private": true,
      "dependencies": {
      "@material-ui/core": "^3.7.1",
      "axios": "^0.18.0",
      "classnames": "^2.2.6",
      "contentful": "^7.0.5",
      "jquery": "^3.3.1",
      "mdbreact": "^4.8.6",
      "prop-types": "^15.6.2",
      "react": "^16.7.0-alpha.2",
      "react-dom": "^16.7.0-alpha.2",
      "react-router-dom": "^4.4.0-beta.6",
      "react-scripts": "2.1.2"
      },
      "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
      },
      "eslintConfig": {
      "extends": "react-app"
      },
      "browserslist": [
      ">0.2%",
      "not dead",
      "not ie <= 11",
      "not op_mini all"
      ]
      }


      index.js



      import React from 'react';
      import ReactDOM from 'react-dom';
      import 'font-awesome/css/font-awesome.min.css';
      import 'bootstrap-css-only/css/bootstrap.min.css';
      import 'mdbreact/dist/css/mdb.css';
      import './index.css';
      import App from './App';
      //import * as serviceWorker from './serviceWorker';

      ReactDOM.render(<App />, 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.
      //serviceWorker.unregister();


      App.js



      import React from 'react'
      import { MDBContainer } from 'mdbreact';

      import FixedNavbarExample from './components/navbar/NavbarPage'



      const App = () => {

      return (
      <div>
      <FixedNavbarExample/>
      <MDBContainer style={{height: 100}} className="text-center mt-5 pt-5">
      </MDBContainer>
      </div>
      )
      }

      export default App


      NavbarPage.js



      import React from 'react';
      import { MDBContainer, MDBNavbar, MDBNavbarBrand, MDBNavbarNav, MDBNavbarToggler, MDBCollapse, MDBNavItem, MDBNavLink, MDBIcon } from 'mdbreact';
      import { BrowserRouter as Router } from 'react-router-dom';

      class FixedNavbarExample extends React.Component {
      constructor(props) {
      super(props);
      this.state = {
      collapse: false,
      };
      this.onClick = this.onClick.bind(this);
      }

      onClick() {
      this.setState({
      collapse: !this.state.collapse,
      });
      }

      render() {
      const bgPink = {backgroundColor: '#e91e63'}
      const container = {height: 1300}
      return(
      <div>
      <Router>
      <header>
      <MDBNavbar style={bgPink} dark expand="md" scrolling fixed="top">
      <MDBNavbarBrand href="/">
      <strong>Navbar</strong>
      </MDBNavbarBrand>
      <MDBNavbarToggler onClick={ this.onClick } />
      <MDBCollapse isOpen = { this.state.collapse } navbar>
      <MDBNavbarNav left>
      <MDBNavItem active>
      <MDBNavLink to="#">Home</MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#">Features</MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#">Pricing</MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#">Options</MDBNavLink>
      </MDBNavItem>
      </MDBNavbarNav>
      <MDBNavbarNav right>
      <MDBNavItem>
      <MDBNavLink to="#"><MDBIcon icon="facebook" /></MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#"><MDBIcon icon="twitter" /></MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#"><MDBIcon icon="instagram" /></MDBNavLink>
      </MDBNavItem>
      </MDBNavbarNav>
      </MDBCollapse>
      </MDBNavbar>
      </header>
      </Router>
      </div>
      );
      }
      }

      export default FixedNavbarExample;


      What I have found so far :





      • I have referenced the following StackOverflow posts




        • link1


        • link2




      • from what I am seeing the problem is in the NavbarPage.js. The articles above tell me 2 things : (First-Thing) to wrap all of the content in <div> which the example link from mdbreact tutorial is already doing & (Second-Thing) to move inside which is also done.


      • I have also tried renaming the import from BrowserRouter as Router to just BrowserRouter, and made corresponding refactoring. Even that resulted in the same error.



      Looking for help in understanding what is causing this problem, to further my understanding in react, mdbreact.










      share|improve this question














      I am hitting this problem constantly, and have been stuck at it for a long time now. I am new to mbdreact library and I have been trying this example of theirs from this link. This has given me too many problems in debugging and understanding what is going on.



      Problem :



      You should not use <Route> or withRouter() outside a <Router>


      The detailed error trace I could pull is as follows :



      Uncaught Error: You should not use <Route> or withRouter() outside a <Router>
      at invariant (browser.js:34)
      at Route.computeMatch (Route.js:96)
      at new Route (Route.js:72)
      at constructClassInstance (react-dom.development.js:13082)
      at updateClassComponent (react-dom.development.js:14978)
      at beginWork (react-dom.development.js:15845)
      at performUnitOfWork (react-dom.development.js:18879)
      at workLoop (react-dom.development.js:18920)
      at HTMLUnknownElement.callCallback (react-dom.development.js:147)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
      at invokeGuardedCallback (react-dom.development.js:250)
      at replayUnitOfWork (react-dom.development.js:18127)
      at renderRoot (react-dom.development.js:19038)
      at performWorkOnRoot (react-dom.development.js:19941)
      at performWork (react-dom.development.js:19851)
      at performSyncWork (react-dom.development.js:19825)
      at requestWork (react-dom.development.js:19680)
      at scheduleWork (react-dom.development.js:19487)
      at scheduleRootUpdate (react-dom.development.js:20191)
      at updateContainerAtExpirationTime (react-dom.development.js:20217)
      at updateContainer (react-dom.development.js:20285)
      at ReactRoot.push../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render (react-dom.development.js:20564)
      at react-dom.development.js:20718
      at unbatchedUpdates (react-dom.development.js:20068)
      at legacyRenderSubtreeIntoContainer (react-dom.development.js:20714)
      at Object.render (react-dom.development.js:20781)
      at Module../src/index.js (index.js:10)
      at __webpack_require__ (bootstrap:782)
      at fn (bootstrap:150)
      at Object.0 (index.js:15)
      at __webpack_require__ (bootstrap:782)
      at checkDeferredModules (bootstrap:45)
      at Array.webpackJsonpCallback [as push] (bootstrap:32)
      at main.chunk.js:1


      Code :



      package.json



      {
      "name": "test",
      "version": "0.0.1",
      "private": true,
      "dependencies": {
      "@material-ui/core": "^3.7.1",
      "axios": "^0.18.0",
      "classnames": "^2.2.6",
      "contentful": "^7.0.5",
      "jquery": "^3.3.1",
      "mdbreact": "^4.8.6",
      "prop-types": "^15.6.2",
      "react": "^16.7.0-alpha.2",
      "react-dom": "^16.7.0-alpha.2",
      "react-router-dom": "^4.4.0-beta.6",
      "react-scripts": "2.1.2"
      },
      "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
      },
      "eslintConfig": {
      "extends": "react-app"
      },
      "browserslist": [
      ">0.2%",
      "not dead",
      "not ie <= 11",
      "not op_mini all"
      ]
      }


      index.js



      import React from 'react';
      import ReactDOM from 'react-dom';
      import 'font-awesome/css/font-awesome.min.css';
      import 'bootstrap-css-only/css/bootstrap.min.css';
      import 'mdbreact/dist/css/mdb.css';
      import './index.css';
      import App from './App';
      //import * as serviceWorker from './serviceWorker';

      ReactDOM.render(<App />, 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.
      //serviceWorker.unregister();


      App.js



      import React from 'react'
      import { MDBContainer } from 'mdbreact';

      import FixedNavbarExample from './components/navbar/NavbarPage'



      const App = () => {

      return (
      <div>
      <FixedNavbarExample/>
      <MDBContainer style={{height: 100}} className="text-center mt-5 pt-5">
      </MDBContainer>
      </div>
      )
      }

      export default App


      NavbarPage.js



      import React from 'react';
      import { MDBContainer, MDBNavbar, MDBNavbarBrand, MDBNavbarNav, MDBNavbarToggler, MDBCollapse, MDBNavItem, MDBNavLink, MDBIcon } from 'mdbreact';
      import { BrowserRouter as Router } from 'react-router-dom';

      class FixedNavbarExample extends React.Component {
      constructor(props) {
      super(props);
      this.state = {
      collapse: false,
      };
      this.onClick = this.onClick.bind(this);
      }

      onClick() {
      this.setState({
      collapse: !this.state.collapse,
      });
      }

      render() {
      const bgPink = {backgroundColor: '#e91e63'}
      const container = {height: 1300}
      return(
      <div>
      <Router>
      <header>
      <MDBNavbar style={bgPink} dark expand="md" scrolling fixed="top">
      <MDBNavbarBrand href="/">
      <strong>Navbar</strong>
      </MDBNavbarBrand>
      <MDBNavbarToggler onClick={ this.onClick } />
      <MDBCollapse isOpen = { this.state.collapse } navbar>
      <MDBNavbarNav left>
      <MDBNavItem active>
      <MDBNavLink to="#">Home</MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#">Features</MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#">Pricing</MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#">Options</MDBNavLink>
      </MDBNavItem>
      </MDBNavbarNav>
      <MDBNavbarNav right>
      <MDBNavItem>
      <MDBNavLink to="#"><MDBIcon icon="facebook" /></MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#"><MDBIcon icon="twitter" /></MDBNavLink>
      </MDBNavItem>
      <MDBNavItem>
      <MDBNavLink to="#"><MDBIcon icon="instagram" /></MDBNavLink>
      </MDBNavItem>
      </MDBNavbarNav>
      </MDBCollapse>
      </MDBNavbar>
      </header>
      </Router>
      </div>
      );
      }
      }

      export default FixedNavbarExample;


      What I have found so far :





      • I have referenced the following StackOverflow posts




        • link1


        • link2




      • from what I am seeing the problem is in the NavbarPage.js. The articles above tell me 2 things : (First-Thing) to wrap all of the content in <div> which the example link from mdbreact tutorial is already doing & (Second-Thing) to move inside which is also done.


      • I have also tried renaming the import from BrowserRouter as Router to just BrowserRouter, and made corresponding refactoring. Even that resulted in the same error.



      Looking for help in understanding what is causing this problem, to further my understanding in react, mdbreact.







      javascript reactjs react-router mdbootstrap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 1 at 6:30









      sudhishkrsudhishkr

      1,07931539




      1,07931539
























          1 Answer
          1






          active

          oldest

          votes


















          6














          Your react-router-dom version (beta.6) is incompatible with mdbreact library.
          If you install stable version ^4.3.1 everything will work fine.






          share|improve this answer
























          • Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

            – sudhishkr
            Jan 2 at 11:35











          • thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

            – sudhishkr
            Jan 2 at 11:59











          • If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

            – sudhishkr
            Jan 2 at 11:59











          • Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

            – Rotarepmi
            Jan 8 at 9:53








          • 1





            You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

            – Rotarepmi
            Jan 8 at 9:56











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993475%2freact-browserrouter-resulting-in-you-should-not-use-route-or-withrouter-out%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          Your react-router-dom version (beta.6) is incompatible with mdbreact library.
          If you install stable version ^4.3.1 everything will work fine.






          share|improve this answer
























          • Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

            – sudhishkr
            Jan 2 at 11:35











          • thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

            – sudhishkr
            Jan 2 at 11:59











          • If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

            – sudhishkr
            Jan 2 at 11:59











          • Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

            – Rotarepmi
            Jan 8 at 9:53








          • 1





            You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

            – Rotarepmi
            Jan 8 at 9:56
















          6














          Your react-router-dom version (beta.6) is incompatible with mdbreact library.
          If you install stable version ^4.3.1 everything will work fine.






          share|improve this answer
























          • Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

            – sudhishkr
            Jan 2 at 11:35











          • thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

            – sudhishkr
            Jan 2 at 11:59











          • If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

            – sudhishkr
            Jan 2 at 11:59











          • Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

            – Rotarepmi
            Jan 8 at 9:53








          • 1





            You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

            – Rotarepmi
            Jan 8 at 9:56














          6












          6








          6







          Your react-router-dom version (beta.6) is incompatible with mdbreact library.
          If you install stable version ^4.3.1 everything will work fine.






          share|improve this answer













          Your react-router-dom version (beta.6) is incompatible with mdbreact library.
          If you install stable version ^4.3.1 everything will work fine.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 11:31









          RotarepmiRotarepmi

          965




          965













          • Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

            – sudhishkr
            Jan 2 at 11:35











          • thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

            – sudhishkr
            Jan 2 at 11:59











          • If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

            – sudhishkr
            Jan 2 at 11:59











          • Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

            – Rotarepmi
            Jan 8 at 9:53








          • 1





            You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

            – Rotarepmi
            Jan 8 at 9:56



















          • Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

            – sudhishkr
            Jan 2 at 11:35











          • thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

            – sudhishkr
            Jan 2 at 11:59











          • If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

            – sudhishkr
            Jan 2 at 11:59











          • Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

            – Rotarepmi
            Jan 8 at 9:53








          • 1





            You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

            – Rotarepmi
            Jan 8 at 9:56

















          Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

          – sudhishkr
          Jan 2 at 11:35





          Thanks @Rotarepmi, hopefully this will fix the problem. Going to give this a try quickly.

          – sudhishkr
          Jan 2 at 11:35













          thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

          – sudhishkr
          Jan 2 at 11:59





          thanks a ton ! I noticed you are part of the mdbreact team from github issues you help answer. Would it be possible for your team to maintain a compatibility table of some sort?

          – sudhishkr
          Jan 2 at 11:59













          If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

          – sudhishkr
          Jan 2 at 11:59





          If you already have one, I definitely might have missed it. If you could point me to it - that will be great.

          – sudhishkr
          Jan 2 at 11:59













          Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

          – Rotarepmi
          Jan 8 at 9:53







          Here is such table: mdbootstrap.com/general/browsers-and-devices But I suppose it doesn't fullfill your needs? :) MDBReact package is continuosly updated, so it is compatible with all newest Stable versions (or at least backward compatible). You've been using beta version of react-router-dom, which caused the problem.

          – Rotarepmi
          Jan 8 at 9:53






          1




          1





          You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

          – Rotarepmi
          Jan 8 at 9:56





          You can see all the mdbreact dependencies (and their versions) in dependencies here: npmjs.com/package/mdbreact

          – Rotarepmi
          Jan 8 at 9:56




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993475%2freact-browserrouter-resulting-in-you-should-not-use-route-or-withrouter-out%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'