How we can remove listeners in React-native-navigation on app kill . Because in the starting of the app there is no root component but just a class there is no componentWillUnMount. I need to remove some listeners on app kill for example react-native-fcm listeners and socket client listeners. Thanks
Asked
Active
Viewed 1,001 times
2 Answers
0
You can unregister listeners when the root component is unmounted.
For example; in this root layout, you can do clean up when navigation.playground.WelcomeScreen
unmounts.
Navigation.setRoot({
root: {
stack: {
id: 'TEST',
children: [
{
component: {
name: 'navigation.playground.WelcomeScreen'
}
}
]
}
}
});

guy.gc
- 3,359
- 2
- 24
- 39
-
Hi I am using react-native-navigation V1 1.1.485 . The solution you provide me is in V2. Can you have any solution for V1 – Parshant Nagpal Sep 16 '18 at 09:46
0
The root component stack unmount as we move to another stack by using Navigation.setRoot there is no parent root here in this navigation where we can register or unregister the listeners.

Parshant Nagpal
- 21
- 5