Might be related to #91
I know component is unmounted when the type of the route is "replace", but I need to set type="push" so that I can set Animations...
When type is push, the component is not unmounted. What can I do ?
Thank you ;)
I'm interested in this too. However, I'm seeing that the component is not unmounted on a replace either. I have event listeners on some of my components that fire multiple times, depending on how the user navigates, because the original component never unmounts:
RouteA (replace) -> push A.1 (listener attaches on WillMount) -> push A.2 -> ...
RouteB (replace) -> RouteA (replace) -> push A.1 (another listener attaches, both fire on events)
Any help is greatly appreciated!
Check RN Navigator component behavior - i believe it doesn't unmount components as well...
@Mokto, @rgoldiez did you manage to find a workaround for your situation? I would like to trigger something on unmount also when the type of route is "push"
In my case, I was able to use the a 'reset' type route, which unmounts and clears the stack. This may or may not be what you're looking for. If you have code that needs to know when something new is push onto the stock (over top of your current view), you can always add an onPush handler and in that handler, broadcast an event that any concerned components listen for and take action when something is pushed on top.
Run into the same issue, had my head scratching, setting type='replace' fixed it.
<Route name="dashboard" type='replace' wrapRouter={false} component={Dashboard} title="Dashboard" />
@michshat whilst replace does demount it, it's used to replace it in the history order, which means if you use it then you can go back (especially on android back button)
@rgoldiez "you can always add an onPush handler" that's probably what I would need, but it seems that it's not an option anymore in V3, although componentWillUnmount is still not triggered with the push actions.
Most helpful comment
Run into the same issue, had my head scratching, setting
type='replace'fixed it.<Route name="dashboard" type='replace' wrapRouter={false} component={Dashboard} title="Dashboard" />