简体   繁体   English

反应在弹出路线上调用的本机导航实验生命周期方法?

[英]React Native Navigation Experimental Lifecycle Method Called on Pop Route?

I'm using NavigationExperimental with React Native. 我正在将NavigationExperimental与React Native一起使用。 Are any of the lifecycle methods invoked when a pop route happens? 发生弹出路由时,是否会调用任何生命周期方法?

For example: Scene A => Scene B 例如:场景A =>场景B

If I pop the route on Scene B, I want Scene A to re-render. 如果在场景B上弹出路线,我希望场景A重新渲染。

FirstPageComponent.js FirstPageComponent.js

 pressBtn() {
    let _this = this;
    const { navigator } = this.props;
    if (navigator) {
      navigator.push({
        name: 'SecondPageComponent',
        component: SecondPageComponent,
        title: 'page2',
        params: {
          name: 'glm',
          getFeedBack: function(text) {
            _this.setState({feedback: text});
          }
        }
      });
    }
  }

SecondPageComponent.js: SecondPageComponent.js:

  pressBtn() {
    const { navigator } = this.props;
    if (navigator) {
      this.props.getFeedBack('Im fine');
      navigator.pop();
    }
  }

call getFeedBack When you pop Second page, the getFeedBack will change the state of First page, then First page will be re-rendered. 调用getFeedBack当您弹出第二页时,getFeedBack将更改第一页的状态,然后将重新呈现第一页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM