react native Actions 实现页面返回回传, 回调数据的两种方法。

方法一:

在页面返回时带参数

Actions.popTo('login');
setTimeout(()=>{
   Actions.refresh({phone:this.state.phoneTextValue,pwd:this.state.passwordValue})
})

在前一页面接受参数:

componentWillReceiveProps(nextProps): void {
    // console.log('componentWillReceiveProps')
   this.setState({phoneTextValue:nextProps.phone,passwordValue:nextProps.pwd})
}

方法二:

前往setting页面 带cellback参数 refresh 。

Actions.setting({refresh: () => { this.getUserInfo() }, })}

在第二个页面要返回时:回调传人的cellback  参数  refresh()。在getUserInfo中实现相关业务代码

Actions.pop(this.props.refresh());

猜你喜欢

转载自blog.csdn.net/qq_36355271/article/details/105520900