reactjs - 无法在 React-Native 中使用导航 && 属性?

标签 reactjs react-native

我正在开发一个 React-Native 项目并发现了一个问题..

一切工作正常,除了我的 HomeStackScreen,我想通过 Prop 传递数据,但也想导航以打开抽屉

const HomeStackScreen = (props, navigation) => (


  console.log("HOME STACK:   " + props.studentData),

  <HomeStack.Navigator headerMode="screen" studentData={props.studentData}>
    <HomeStack.Screen name = "Home" children={() => <HomeScreen studentData={props.studentData} />} options={{
      title:'Home',
      headerStyle: {
        backgroundColor: '#e67e22',
        

      },
      headerRight: () => (
        <Icon.Button name="build" size={30} 
        backgroundColor="#e67e22" color="white" paddingLeft= {15} onPress= {() => navigation.
        openDrawer()}></Icon.Button>
      )
    }}/>
  </HomeStack.Navigator>

);

这是我的代码,但是当我编写时

const HomeStackScreen = (props) => (

const HomeStackScreen = ({navigation}) => (

一切正常,但是当我想同时使用两者时,我收到错误,告诉我其中一个不是函数

最佳答案

你应该像这样使用它们:

const HomeStackScreen = (props) => {
  const {navigation,studentData} =  props ;
  return ...

}

关于reactjs - 无法在 React-Native 中使用导航 && 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65541407/

相关文章:

reactjs - 如何在屏幕尺寸发生变化时添加或删除类名

javascript - 将对象传递给可重用 View 会出现错误 : null is not object (evaluating . ..)

javascript - React-Native 不变违规 : Element type is invalid

reactjs - 有条件地禁用 antd 表中的 selectAll 复选框

javascript - 在 package.json 中更改代理不起作用

reactjs - React hooks,每个 child 一个

javascript - 我们如何更新 firebase 云存储中的现有图像?

Firebase 限制每个查询一个 "array-contains-any"- 如果我需要多个怎么办?

javascript - React Native 模态选择器中的全屏

reactjs - 阻止 `useSelector` 重新渲染组件?