Pass value between component in React Native Navigator

前端 未结 6 2054
后悔当初
后悔当初 2020-12-03 10:37

How can I pass data from sceneA to sceneB with Navigator in React Native?

I\'m using this to go to sceneB:



        
6条回答
  •  被撕碎了的回忆
    2020-12-03 11:06

    1.While passing the data from scene A to scene B, you must specify in the navigator tag that you are also passing the data with route. ex.

    if(route.name == 'home') {
          return 
        }
    

    send data from scene A ex.this.props.navigator.push({name:'sceneB',data:{name:this.state.name},});

    in scene B access data like this ex. this.props.data.name and you get the data from scene A to scene B

提交回复
热议问题