导航导航抽屉时,React本机不刷新屏幕

问题描述 投票:0回答:1

我开发了一个应用程序使用导航抽屉。导航屏幕使用导航抽屉。但导航时我不会刷新屏幕。我解决了这个问题

react-native react-navigation
1个回答
2
投票

componentDidMount()中添加以下代码

componentDidMount() {
    this.subs = this.props.navigation.addListener("didFocus", () =>
      //Your logic, this listener will call when you open the class every time
    );
  }

并且不记得在componentWillUnmount()删除监听器,

componentWillUnmount() {
    this.subs.remove();
  }
© www.soinside.com 2019 - 2024. All rights reserved.