React native 如何修改DroperAvigatorItems项目

React native 如何修改DroperAvigatorItems项目,react-native,react-navigation,react-navigation-drawer,React Native,React Navigation,React Navigation Drawer,在fromDrawerNavigatorItems中,它具有以下属性: 项-可以修改或覆盖路由数组 它说你可以修改数组 我该怎么做 它没有解释什么是“路线数组”。只是线?一个物体 我想做的一个例子是获取完整的数组,并在末尾添加一个额外的数组,如 items: [...items, someNewItem] 一种解决方案是定义定制组件。此外,我们可以利用Redux来管理状态 摘自我创建的一个应用程序: //The navigation part const MainDrawer=create

在from
DrawerNavigatorItems
中,它具有以下属性:

  • -可以修改或覆盖路由数组
它说你可以修改数组

我该怎么做

它没有解释什么是“路线数组”。只是线?一个物体

我想做的一个例子是获取完整的数组,并在末尾添加一个额外的数组,如

items: [...items, someNewItem]

一种解决方案是定义定制组件。此外,我们可以利用Redux来管理状态

摘自我创建的一个应用程序:

//The navigation part
const MainDrawer=createDrawerNavigator({
  MainNavigation,
  K:KChartViewScreen
},{
contentComponent:CoinDrawer,
edgeWidth:-1 //to disable gesture from bound open the drawer in unexpected screen. but you could do some work to enable it and without problem, I just handle in an easy way.
});

以下为出票人:

class CoinDrawer extends React.Component{
renderMarkets(){
   ...
}
render(){
        return (
            <View>


            <ScrollView>
                <SafeAreaView style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>

                {this.renderMarkets()}
                </SafeAreaView>

            </ScrollView>
            </View>
        )
    }

function mapStateToProps(state){
    return {
        config:state.config,
        crypto:state.crypto,
        trade:state.trade
    }
}

export default connect(mapStateToProps,{SetCurrentMarket})(CoinDrawer);

class.Component{
renderMarkets(){
...
}
render(){
返回(
{this.renderMarkets()}
)
}
函数MapStateTops(状态){
返回{
config:state.config,
加密:state.crypto,
贸易:国贸
}
}
导出默认连接(mapStateToProps,{SetCurrentMarket})(Cointrawer);

希望这能对您有所帮助。

您可以在导航文件中传递抽屉导航项。您可以创建一个如下所示的导航项

import { createDrawerNavigator } from 'react-navigation-drawer'
const MainNavigator = createDrawerNavigator(
  {
    Main,
    Landing,
  },
  {
    contentComponent: Drawer,
  },
)
const AppNavigator = createStackNavigator(
  {
    MainNavigator,
    Account,
    Success,
  },
  {
    initialRouteName: 'MainNavigator',
    headerMode: 'none',
  },
)
我希望您理解,我们可以制作不同类型的导航器,如
开关
堆栈
抽屉
,等等。 之后,您可以在AppNavigator中调用抽屉导航器,如下所示

import { createDrawerNavigator } from 'react-navigation-drawer'
const MainNavigator = createDrawerNavigator(
  {
    Main,
    Landing,
  },
  {
    contentComponent: Drawer,
  },
)
const AppNavigator = createStackNavigator(
  {
    MainNavigator,
    Account,
    Success,
  },
  {
    initialRouteName: 'MainNavigator',
    headerMode: 'none',
  },
)
现在,无论您将在MainNavigator对象中插入什么路由,它都将显示在抽屉中。 可能有几种使用导航服务的方法,我使用了这一种。
希望这有帮助。

但是你在哪里使用
DrawerNavigatorItems
?我没有使用它。我已经尽力让它在我的案例中发挥作用,但被放弃了。这是一个旧版本,请使用@react navigation/drawer和@react navigation/native更新。这是一个旧版本,请使用@react navigation/drawer和@react navigation/native更新