我的堆栈导航器有问题...我有两个导航
tabNavigator
-> main
-> stackNavigator
-> page 1
-> page 2
所以我想当我在第 2 页并单击主(tabNavigator)时,我的 stacknavigator 重置到第 1 页...
应用程序.js
import React, { Component } from 'react';
import { Text, Button, View } from 'react-native';
import { TabNavigator, StackNavigator, NavigationActions} from 'react-navigation';
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'PageOne'})
]
})
class PageOneScreen extends Component {
render() {
return (<View><Text> PageOne </Text><Button title="next" onPress={() => this.props.navigation.navigate('PageTwo')} /></View>);
}
}
class PageTwoScreen extends Component {
render() {
return (<View><Text> PageTwo </Text><Button title="reset" onPress={() => this.props.navigation.dispatch(resetAction)} /></View>);
}
}
class MainScreen extends Component {
render() {
return (<Text> Main </Text>);
}
}
const stackNav = StackNavigator({
PageOne: {screen: PageOneScreen},
PageTwo: {screen: PageTwoScreen}
});
const tabNav = TabNavigator({
Main: {screen: MainScreen},
Stack: {screen: stackNav}
});
export default tabNav;
但我不管理