A
A
Andrey2020-02-05 18:38:36
React Native
Andrey, 2020-02-05 18:38:36

Stateful navigation between two screens?

I use react-native c react-navigation v.4 for navigation.
It is necessary to switch between two screens keeping the state of both screens (not unmounting them).
Like now:

const PagesStack = createStackNavigator({
    ... тут еще экраны, на которые можно переходить из Feed
});
const AppStack = createSwitchNavigator({
    Feed: FeedScreen,
    Pages: PagesStack
}, {
    resetOnBlur: false,
    initialRouteName: 'Feed'
});

Problems:
- if you move from Feed to a screen from the Pages stack, then the Feed will be unmounted
- Feed has lost its header

Tried to do from - Feed stack with a single screen - the header appears, but still, when switching between screens, their state is not saved.

If necessary, ready to upgrade to version 5 of react-navigation.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question