0
I have an application in React Native, and I use the DrawerNavigator
as a navigation menu, but when I go from one screen to the other, I would like the previous one to be destroyed.
So when I get back to it, recharge everything like it’s the first time I’m accessing it, some idea of how to do it?
Example of how I create mine stackNavigator
:
const StackHome = createStackNavigator({ home: {
screen: Object.assign(home,
{
navigationOptions: ({ navigation }) => (
Object.assign({
title: "Home",
headerLeft: <DrawerIcon navigation={navigation} />,
headerRight:<View></View>
}, navigationOptions)
)
})}}, { navigationOptions: {
title: "Inicial",
drawerIcon: () => (
<Icon name="home" size={20} color="#00374c" />
)}});
And so I create mine DrawerNavigator
:
const drawMenu = createDrawerNavigator({ StackHome, StackPessoas},{
initialRouteName: 'StackHome',}, {
drawerPosition: 'left',
drawerBackgroundColor: 'red',
drawerWidth: 200, });
I own several const creating StackNavigator
, and pass all as parameters in the Drawer
to add to Menu.
But I can’t destroy one screen when I step out of it and navigate to another.
Could you add some sample code so we can better understand your problem? I’ve been working hard with Act-Native-Navigator, who knows I can help you....
– Marconi
@Marconi edited my question above and added the stack and Drawer Navigator I’m using for my navigations, if you can give me a hand with that. Thanks in advance
– Luan Martins Gepfrie
Use the reset, is exactly what you need. If you can’t get me an answer.
– Marconi
I’m not being able to reset because I have different 'Stacknavigator', so each one has an index starting from scratch, I can reset when I have all the routes inside a 'Stacknavigator', but with one for each route I’m not getting it. I return the error: 'Exceptionsmanager.js:74 Error: Error: There is no route defined for key saldocc. Must be one of: 'home' '.
– Luan Martins Gepfrie