1

我已经使用反应导航在反应本机应用程序中创建了一个抽屉导航菜单,并添加了几个屏幕,如屏幕 1,2...等。现在在我的抽屉菜单中,我有应用程序图标,下面有抽屉菜单,所以现在按下这个图标我需要重新渲染屏幕 1。

class CustomDrawer extends Component {
    constructor(props) {
        super(props);
    }

    onAppIconClicked() {
        //here update the state of Screen 1
    }

    render() {
        return (
            <SafeAreaView style={styles.drawercontainer}>
                <View style={styles.drawermenu}>
                    <TouchableOpacity
                        style={styles.drawericon}
                        onPress={this.onAppIconClicked.bind(this)}
                    >
                        <Image
                            source={require("./src/images/mainicon.png")}
                            style={{ height: height(15), width: width(17), borderRadius: height(15) / 2 }}
                            resizeMode="contain"
                        />
                    </TouchableOpacity>
                </View>
                {/* some drawer items component */}
            </SafeAreaView>
        )
    }
}

const DrawerNavigatorExample = createDrawerNavigator({
    // Drawer Optons and indexing
    Screen0: {
        //Title
        screen: Screen1,
        navigationOptions: ({ navigation }) => {
            return {
                drawerLabel: () => null,
            }
        }
    },
    contentComponent: CustomDrawer
})

export default createAppContainer(DrawerNavigatorExample);

在此处输入图像描述

4

0 回答 0