The biggest problem of StackNavigator
is that components won't be unmounted, i.e., componentWillUnmount()
won't be invoked.
But I need this component stage to unbind event, or to do other things. And that's why I started using DrawerNavigator
.
But this brings another issue which StackNavigator
would solve automatically.
I have a component which loads data from the server. In this component, I just show the summery, and whenever a user clicks on that, another component appears to show details. That means there are two components (screen). So, a user navigates to detail screen, (AppNavigator.router.getStateForAction(NavigationActions.navigate({routeName: action.route}), currentState);
) and then he/she pressed (hardware) back button, as I override the default behavior of this event (close the app), he/she will navigate to list screen. Now, the problem is, say he/she was in 15th data, now when he/she navigated from detail screen, the scrollbar is in first data! Had I used StackNavigator
, the scrollbar would have been in 15th data.
I implemented this using ScrollView
, and FlatList
. Used onMomentumScrollEnd
props to get more data from the server.
So, how can I solve this, the scrollbar should be placed where it was last time, and at the same time get the feature of componetWillUnmount
?