[英]How to pass in navigation props into a functional component screen through React Navigation?
I have a functional component screen with a React Native FlatList of custom "Tasks".我有一个带有自定义“任务”的 React Native FlatList 的功能组件屏幕。 I want to be able to navigate from a task to another functional component, "TaskEditScreen" and pass some props to the screen as well.
我希望能够从一个任务导航到另一个功能组件“TaskEditScreen”并将一些道具传递到屏幕。
<TouchableOpacity onPress={()=>{navigation.navigate('Task Edit')}}>
<Feather
name="edit"
size={35}
color="black"
style={{
margin: 5
}}
/>
</TouchableOpacity>
The onPress function works and it navigates me to the correct screen, but how do I also pass in some kind of props or data to this screen? onPress 函数可以工作,它将我导航到正确的屏幕,但是我如何还将某种道具或数据传递到此屏幕?
Documentation: https://reactnavigation.org/docs/params文档: https : //reactnavigation.org/docs/params
<TouchableOpacity onPress={() => { navigation.navigate('Task Edit', {someParam: "someValue"}) }}>
<Feather
name="edit"
size={35}
color="black"
style={{
margin: 5
}}
/>
</TouchableOpacity>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.