React Native,自定义 DrawerContent 导航器问题

React Native, Custom DrawerContent navigator issue

我有一个自定义 DrawerContent 组件,我无法使用 navigator.navigate('DrawerHelp').

从它导航到屏幕

我仍然收到这个错误,我真的不知道如何解决它。

我正在尝试从“帮助”按钮导航到它自己的名为 DrawerHelp 的组件。

问题带有负载 {"name":"DrawerHelp"} 的操作 'NAVIGATE' 未被任何导航器处理

下面是我的代码。

function DrawerComponent() {
    return (
        <Drawer.Navigator 
            drawerContentOptions={{activeBackgroundColor: '#efefef', activeTintColor: '#000000'}}
            initialRouteName="Tabs" 
            drawerStyle={{ backgroundColor:'#ffffff', width:'85%', paddingBottom: 50 }} 
            drawerContent={ 
                props => ( <CustomDrawerContent {...props} /> )
            }>
            <Drawer.Screen name="Dashboard" component={Tabs} options={{
                drawerIcon: config => <Ionicons name={'ios-home'} size={18} color={'#444'} headerTitle="AAA" />,
            }} />

            <Drawer.Screen name="Help" component={DrawerHelp} 
                options={{
                    drawerIcon: config => <Ionicons name={'ios-people-circle-outline'} size={18} color={'#444'}/>,
                }}
            />
        </Drawer.Navigator>
    );
}
export function CustomDrawerContent (props) {

    const [ tabs, setTabs ] = useState([
        { 
            name: 'Help',
            icon: 'ios-call',
            borderColor: '#e7c53f',
            backgroundColor: '#fff',
            color: '#e7c53f',
            fontWeight: '500'
        },{ 
            name: 'Share',
            icon: 'ios-megaphone',
            borderColor: '#e7c53f',
            backgroundColor: '#fff',
            color: '#e7c53f',
            fontWeight: '500'
        },{ 
            name: 'Logout',
            icon: 'ios-log-out',
            borderColor: '#e7c53f',
            backgroundColor: '#fff',
            color: '#e7c53f',
            fontWeight: '500'
        }
    ]);

    return (
        <DrawerContentScrollView {...props}>
            <DrawerItemList {...props} />
            <View style={{ padding: 15 }}>
                <View style={{ 
                    flexDirection: 'row', 
                    justifyContent: 'space-between',
                    height: 50,
                    alignItems: 'center'
                }}>
                    {
                        tabs.map((tab) => {
                            return (
                                <TouchableOpacity
                                    key={tab.name}
                                    style={{
                                        height: '100%',
                                        flex: .32,
                                        alignItems: 'center',
                                        borderWidth: .5,
                                        borderColor: tab.borderColor,
                                        backgroundColor: tab.backgroundColor,
                                        borderRadius: 10,
                                        flexDirection: 'row',
                                        justifyContent: 'space-evenly'
                                    }}
                                    onPress={() => {
                                        if(tab.name == 'Logout') {
                                            // navigation.toggleDrawer();
                                        }

                                        if(tab.name == 'Share') {
                                            // onShare();
                                        }

                                        if(tab.name == 'Help') {
                                            props.navigation.navigate('DrawerHelp');
                                        }
                                    }}>
                                    <Ionicons name={tab.icon} size={18} style={{ color: tab.color }} />
                                    <Text style={{ color: tab.color, fontWeight: tab.fontWeight }}>{trans(tab.name, cntx.lang)}</Text>
                                </TouchableOpacity>
                            )
                        })
                    }
                </View>
            </View>
        </DrawerContentScrollView>
    );
}

它不起作用,因为您定义了名称为 'Help'

的 DrawerComponent
<Drawer.Screen name="Help" component={DrawerHelp} 
  options={{drawerIcon: config => <Ionicons name={'ios-people-circle-outline'} size={18} color={'#444'}/>
                

if(tab.name == 'Help') {
 props.navigation.navigate('DrawerHelp'); <== Change here to Help not DrawerHelp
}