reactjs - 在文本输入中发送值反应原生
问题描述
本国的,
这里我从第一页取值。
constructor(){
super();
this.state = {
selectPickup:'',
}
}
ongNavigationDetail = ()=>{
let params = {
pickup : this.state.selectPickup
}
console.log(params)
// send to third page
}
render() {
const userLocation = this.props.navigation.getParam('pickup'); // get value from first page
return (
<CardItem header>
{/* <Text style={{ fontSize: 12}}>{userLocation}</Text> */}
<Input onChangeText={userLocation => this.setState({selectPickup:userLocation})} value={userLocation}/>
</CardItem>
<Button block info style={styles.MainBtn} onPress={this.ongNavigationDetail}>
<Text style={styles.btnText}>Next</Text>
</Button>
)}
在第二页上,这里我取值userLocation发送第三次行程,但是当我控制台时,该值未定义,爆炸在哪里?
解决方案
我认为目前,您的导航对象无法访问getParams
功能。也许您可以像这样简单地访问它。
this.pros.navigation.route.params
推荐阅读
- node.js - 无法通过提供 req.body 创建模型
- python - 从各种版本的python导入
- jms - JBoss EAP 7.1 中的 JMS 桥接器没有将消息推送到目的地
- c++ - 如何在我的头文件中包含 pcl 而不抛出“没有这样的文件或目录错误”?
- django - 可以使用 Auth0 JWT 令牌向 Django 后端发送 POST 请求吗?
- c# - 如果在“等待”之后抛出,则从任务中抛出的异常被吞没
- .net - 从 Getter 中调用属性 Setter 不会执行 Setter?
- php - 如何通过传入 ID 更改数组中的字段值
- git - 恢复 git 重置
- class - 如何定义一个类,其中某些边缘对于 OrientDB 中的所有分配记录都是强制性的?