0

I want to use routing outside where the router object is created. How can I do that ?

<div className="col-sm-2 hidden-xs sidebar-container-wrapper">
  <Sidebar currentUrl={currentUrl}/>
</div>
<div className="col-sm-10 col-xs-12 groups-container-wrapper">
  <Provider store={ this.myStore }>
    <Router history={ history } onUpdate={() => window.scrollTo(0, 0)}>
      { routes }
    </Router>
  </Provider>
</div>

1 Answers1

1

Programmatically push state. Or, put the links under Router to use Link...

Also, the HoC is available for newer versions.

Community
  • 1
  • 1
goldbullet
  • 602
  • 4
  • 10
  • I am using Link in sidebar which needs color change on route change. How to handle this – blancVector Aug 25 '16 at 14:18
  • If you're using redux, you can use something like react-router-redux to put the route info in redux store so you can connect() your sidebar and receive the update from there. Or, again the most common way is to put the sidebar in a "shell" component to render the main content and the sidebar both where child route dictates which component to be mounted for the main content that the shell component renders. – goldbullet Aug 25 '16 at 14:23
  • can i use Link using connect in my component ? – blancVector Aug 25 '16 at 16:59