【问题标题】:send value in text input react native在文本输入中发送值反应本机
【发布时间】:2020-09-18 06:10:40
【问题描述】:

原生的,

这里我取第一页的值。

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

【问题讨论】:

    标签: reactjs navigation state native setstate


    【解决方案1】:

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

     this.pros.navigation.route.params
    

    【讨论】:

    • 这里我用的是react navigation 4,数据已经出现了,请问如何使用userLocation发送到第三页
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-09
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    相关资源
    最近更新 更多