首页 > 解决方案 > React Native:如何从按钮传递道具?

问题描述

知道如何将道具从按钮传递到通过引用访问的组件吗?

组件:<RBSheet ref={refRBSheet} > </RBSheet>

来电按钮:<Button title="open" onPress={() => refRBSheet.current.open()} />

标签: reactjsreact-nativeexpo

解决方案


您必须使用React.forwardref 传递ref prop to other components.

有关更多信息,请阅读此内容。

https://reactjs.org/docs/forwarding-refs.html


推荐阅读