mardi 4 avril 2017

react-router current route/params in navigation

All,

What is the recommended approach to retrieve the current state of routing?

(seeing that react-router-redux is not fully compatible with v4 yet)

The pattern I am using is - I imagine - a common one:

<MenuItem active={route === '/foo'}><Link to='/foo' /></MenuItem>

where route is a temp state derived from routing props ... however routing props like match/history/location routing params are not passed to the navigational components (b/c they should appear no matter what)

So, our options are

  • Make the navigation a Route via <Route />
  • Use redux (wait for v4 support or contribute)
  • Use context (seems like a bad way to do business)

Any other more elegant options?




Aucun commentaire:

Enregistrer un commentaire