You should not use Route or withRouter() outside a Router when using react-router 4 and styled-component in react

后端 未结 5 841
走了就别回头了
走了就别回头了 2020-12-18 17:57

I\'m trying to build my first portfolio website and got stuck in routing using react-router-dom 4.2.2 and styled-components 2.2.3.

error message: You should

5条回答
  •  -上瘾入骨i
    2020-12-18 18:15

    Make sure you wrap the main react render code in the Router. For example, with react-dom you need to wrap the app in Browser-Router. If this is a Udacity project, this is typically the index.js file.

    import { BrowserRouter } from 'react-router-dom';
    
    ReactDOM.render(
       
         
       
    
      , document.getElementById('root'));
    

提交回复
热议问题