[英]Passing String value from one page to another page in React-Native
I am trying to capture user input value and set it into a state and pass the new state (updated value) to second page to be used in a function. 我正在尝试捕获用户输入值并将其设置为一种状态,并将新状态(更新值)传递给要在函数中使用的第二页。
The overall app is to create a name for a group chat and pass the NAME of group to the next page to be used as one of the parameters in the createGroup()
function. 整个应用程序是为群组聊天创建一个名称,并将群组的名称传递到下一页以用作createGroup()
函数中的参数之一。
The concept code would be having this.state.channelName
and when user input new value into TextInput
i will capture the string value and _onChangeText(newName){this.setState({channelName: newName})}
. 概念代码将具有this.state.channelName
,当用户向TextInput
输入新值时,我将捕获字符串值和_onChangeText(newName){this.setState({channelName: newName})}
。
After that i will have a button to push
to a new page and use the newName
in the function. 之后,我将有一个按钮来push
送到新页面并在函数中使用newName
。
The result should be having the groupName that contains all the selected users. 结果应该是包含所有选定用户的groupName。
Hope i made myself clear thank you 希望我明确表示谢谢
The pass data during navigation using react-navigation 使用react-navigation在导航期间传递数据
this.props.navigation.navigate(component, { param1: value1, param2: value2, ...})
If you want to update the state for another component, you must maintain the state in redux / flux and update the state in this component and map the state to a prop in next component. 如果要更新另一个组件的状态,则必须在redux / flux中维护该状态,并更新该组件中的状态,并将该状态映射到下一个组件中的prop。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.