React Native:如何通过按钮传递道具?

问题描述 投票:0回答:1

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

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

呼叫方按钮:<Button title="open" onPress={() => refRBSheet.current.open()} />

reactjs react-native expo
1个回答
0
投票

您必须使用React.forward引用来传递ref prop to other components

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

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

© www.soinside.com 2019 - 2024. All rights reserved.