【问题标题】:React Navigation: Send additional props in CustomDrawerContentReact Navigation:在 CustomDrawerContent 中发送额外的道具
【发布时间】:2022-01-07 17:15:25
【问题描述】:

在我的 React Native 项目中,我使用带有自定义抽屉的 React Navigation (5)。抽屉导航器看起来像这样,里面有一些屏幕。

<Drawer.Navigator drawerContent={(props) => <CustomDrawerContent {...props} />} >
</Drawer.Navigator>

如何将一些额外的道具传递给CustomDrawerContent?假设我有一些像user_type 这样的数据。我怎样才能将它与道具一起发送?

【问题讨论】:

    标签: react-native react-navigation


    【解决方案1】:

    试试这个

    const moreData = {}
    
    <Drawer.Navigator drawerContent={(props) => <CustomDrawerContent {...props} moreData={moreData} />} >
    </Drawer.Navigator>
    

    然后记录您的 CustomDrawerContent 道具。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-16
      • 2018-04-02
      • 2020-07-13
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      相关资源
      最近更新 更多