1. 程式人生 > >react navigation傳值給上一頁面

react navigation傳值給上一頁面

reac 組件 .get value cto oba info state getpara

使用新的導航組件react navigation,傳值方式略微發生了一些改變

A頁面到B頁面

pushaddremark(){
    let _this=this;
    this.props.navigation.navigate("addRemarks",
    {
      info:this.state.strdate+this.state.day+"",

      getparams(textvalue){
        _this.fetchStories(textvalue);
      }

    });
}

B頁面代碼

constructor(props) {
    super(props);
    
this.state = { params:this.props.navigation.state.params, todaytime:"this.props.todaytime", textvalue:"" }; } presssave(){ this.state.params.getparams(this.state.textvalue); this.props.navigation.goBack(); }

react navigation傳值給上一頁面