javascript - Resetting the navigation stack for the home screen (React Navigation and React Native) -
i've got problem navigation of react navigation , react native. resetting navigation , returning home screen.
i've build stacknavigator inside of drawernavigator, , navigation between home screen , other screens working. problem is, navigation stack grows , grows. i'm not sure how remove screen stack.
for example when going home screen settings screen, entry screen , lastly again home screen, home screen twice in stack. button not out of app, again entry screen.
when selecting home button again reset of stack great, don't know how this. here tried other person similar problem, solution didn't work me.
const stack = stacknavigator({ home: { screen: home }, entry: { screen: entry }, settings: { screen: settings } }) export const drawer = drawernavigator({ home: { screen: stack }}, { contentcomponent: hamburgermenu } )
and simple example of drawer screen
export default class hamburgermenu extends component { render () { return <scrollview> <icon.button name={'home'} borderradius={0} size={25} onpress={() => { this.props.navigation.navigate('home')}}> <text>{i18n.t('home')}</text> </icon.button> <icon.button name={'settings'} borderradius={0} size={25} onpress={() => { this.props.navigation.navigate('settings')}}> <text>{i18n.t('settings')}</text> </icon.button> <icon.button name={'entry'} borderradius={0} size={25} onpress={() => { this.props.navigation.navigate('entry')}}> <text>{i18n.t('entry')}</text> </icon.button> </scrollview> } }
i hope can me. essential part of navigation , solution great!
this how :
reset(){ return this.props .navigation .dispatch(navigationactions.reset( { index: 0, actions: [ navigationactions.navigate({ routename: 'menu'}) ] })); }
at least replace 'menu' 'home'. may want adapt this.props.navigation implementation.
Comments
Post a Comment