首页 > 解决方案 > 在文本输入中发送值反应原生

问题描述

本国的,

这里我从第一页取值。

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发送第三次行程,但是当我控制台时,该值未定义,爆炸在哪里?

标签: reactjsnavigationstatenativesetstate

解决方案


我认为目前,您的导航对象无法访问getParams功能。也许您可以像这样简单地访问它。

 this.pros.navigation.route.params

推荐阅读