It will be great if we get some info about the router, and state, when the onUpdate callback is raised. Also, it is impossible to use the addTransitionHook, before, or during, the React.render(
+1
I'm trying to implement a router store for v1.0.0-beta3 so I can replicate fluxible-router's behavior (so it's just a HOC, store, and an action), but it's proven to be tricky.
You can get info about router state from this.
Something like:
<Router
history={history}
routes={routes}
onUpdate={function() {
store.dispatch(routerStateChange(this.state));
}}
/>
@faergeek That works, thank you!
What's the reason for not passing on information through arguments?
Now it is potentially an issue whenever someone (like me, currently) would like to have access to both the scope of the component as the scope of the onUpdate handler.
export default class App extends React.Component {
handleUpdate () {
// now it's impossible to access the `this` scope of the `onUpdate`-handler,
// which means no reference to the state of the router
}
render () {
return (
<Provider store={store}>
{() => <Router
history={history}
children={routes}
// bind the handler to another scope
onUpdate={this.handleUpdate.bind(this)}
/>
}
</Provider>
)
}
}
Good question.
/cc @mjackson @ryanflorence
Most helpful comment
You can get info about router state from
this.Something like: