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

后端 未结 5 847
走了就别回头了
走了就别回头了 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:03

    Well you're using a NavLink outside of the BrowserRouter/HashRouter (whatever you're using)

    You said it yourself

    You should not use Link outside a Router

    Make sure that you have the structure like this

    // App render or whatever
    render() {
      return (
        
           
           {`whatever else you doin'`}
        
      );
    }
    

    You must always render them inside a Router

提交回复
热议问题