首页 > 解决方案 > 功能组件中的自定义抽屉 screenProps

问题描述

我正在尝试将我的状态从父组件传递给子组件。

到目前为止,它看起来像这样,但我知道它不是正确的方法,但我似乎无法理解它是如何工作的。

<Drawer.Screen
      name="Home"
      component={Home}
      screenProps={{
        ref: ref,
        setRef: setRef,
        dataSourceCords: dataSourceCords,
        setDataSourceCords: setDataSourceCords,
        scrollHandler: scrollHandler
      }}          
 />

然后在子组件中我试图这样称呼它们:

export default function Home ({ setRef, dataSourceCords, setDataSourceCords, scrollHandler})

我对这一切都很陌生,所以可能是一些非常基本的理解,但我似乎无法让它工作,我发现的所有示例都使用类组件。提前感谢您的帮助!

标签: react-nativenavigation-drawerreact-propsreact-native-drawer

解决方案


推荐阅读