-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Router - add a hook for initial state #102
Comments
+1 I recently faced a situation, where this would have helped. In my case, I need to do some page-level initialization (non-React) upon rendering any page--including the initial page. Either of your suggestion would work fine for my use case. I guess calling Alternatively, since Router is a React component, I wonder if there is a way for users to specify |
@ramnivas smart - this works fine for me: val routerComponent = {
Router.componentUnbuilt(router)
.componentDidMount(scope ⇒ setWindowTitle(scope.state))
.buildU
} |
@codingismy11to7 Cool! I will try the same shortly. |
@japgolly if that's supported (and will remain supported), maybe a line in the router docs pointing that out would be better than some new method of hooking into the initial state |
Good on you for looking around, I'd forgotten about that function. That
method is there exactly for these kind of situations (ones that I didn't
foresee). You're safe to use it, it'll be staying around. A note in the
docs would be nice; PR?
As to whether or not to add a hook, let's keep this open.
|
It works but feel hacky to me as we have to unbuilt then build the router. |
Closed via 93bbc5f. There's a new Router coming in 0.9 that fixes this. In |
It'd be nice to have a way to hook into the Router so that the initial location can be hooked (like the
onRouteChange
hook), or havingonRouteChange
called for the initial load. Not super important, just setting the window title in my case, but don't want to have client-side code changing titles withRoutingRules.Loc
matches duringonRouteChange
and then a different piece of code on the server operating on/path
strings just for the initial page load.The text was updated successfully, but these errors were encountered: