react-native路由反向传值

pageOne

    this.props.navigation.navigate('pageTwo', 
      { 
        callback: ((data) => { //回调函数
            this.setState({
                data: data
            })
        })
      })

pageTwo

        if (this.props.navigation.state.params.callback) {
          this.props.navigation.state.params.callback(data)
        }
//下面操作是返回
        const backAction = NavigationActions.back();
        this.props.navigation.dispatch(backAction);

当然需要相关的模块引入import { NavigationActions } from 'react-navigation';

https://blog.csdn.net/weixin_41534645/article/details/80149803

你可能感兴趣的:(react-native路由反向传值)