React native router flux reset scenes from navigation stack

Abdennacer Lachiheb picture Abdennacer Lachiheb · Sep 13, 2017 · Viewed 7k times · Source

I have a scene ( lets called sceneA ) where a lot of data is rendered inside a listview, so after navigating to another scene, the ui become very slow and laggy because sceneA still in the navigation stack, I tried to solve this by calling: Actions.sceneA({type: "reset"}) inside componentWillUnmount() of sceneA, but that doesn't seem to work as componentWillUnmount() is never called after navigating to another scene, so is there a way to reset previous scenes when navigating inside the app?

Answer

Vahid Boreiri picture Vahid Boreiri · Sep 13, 2017

You can use the <scene/> tag like this:

<Scene type="reset" key="someKey" component={someComponent} .../>

In this way if you go to the scene above, the navigation stack will reset.