首页 > 解决方案 > StackNavigator 中的 TabNavigator 并且不会推送新页面

问题描述

反应导航 1.x

使用Redux

我的堆栈导航器:

export const MyAppStackNavigator = StackNavigator({
    ......
}, {
    initialRouteName: "TabBase",
    navigationOptions: ({navigation, screenProps}) => {
    },
    transitionConfig: () => ({
        screenInterpolator: CardStackStyleInterpolator.forHorizontal
    })
});

和我的 TabNavigator(AppTabNavigator):

const AppTabNavigator = TabNavigator(
    {
        Page1: {
            screen: Page1,
        },
    },
    {}
)

export default class TabBase extends Component {
    render() {
        return (
            <View styles={{
                flex: 1
            }} >
                <AppTabNavigator/>
            </View>
        )    
    }
}

Page1中的一个按钮 onPress 将推送一个新页面

this.props.navigation.navigate("Page2");

但这是行不通的。

如果MyAppStackNavigator 设置initialRouteName: "AppTabNavigator"

this.props.navigation.navigate("Page2");

正在工作中。

但是我需要在 TabBase 中做一些其他的事情,我应该怎么做,让按钮工作?

标签: react-nativereact-navigation

解决方案


推荐阅读