react-native - 返回时React Navigation重新渲染上一页

标签 react-native react-navigation

使用 Stack Navigator 返回时刷新上一页的最佳方式是什么。在我返回的页面上似乎没有触发生命周期 Hook 。我只是使用基本示例和 this.props.navigation.goBack()

最佳答案

您可以使用 addListener为了这

componentDidMount() {

    this.props.navigation.addListener(
      'didFocus',
      payload => {
        this.forceUpdate();
      }
    );

}

关于react-native - 返回时React Navigation重新渲染上一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45837208/

相关文章:

react-native - React Native Debug模式抛出错误,为什么会这样?

javascript - React - 为react-i18next调用useTranslation时无效的钩子(Hook)调用

javascript - 使用 Redux 时 react native 文本输入闪烁

node.js - 获取 TypeError : undefined is not an object (evaluating '_mathjs.default.fraction' ), React-Native

javascript - react-navigation:如何根据当前选项卡更改 tabBar 颜色

javascript - 从平面列表项导航到另一个屏幕

react-native - react 导航 : How do avoid screen re-rendering when not visible

react-native - React Native 无法从 > 不同组件的函数体内部更新组件

javascript - 如何在 React-Native 中获取键盘的高度?

react-native - 使导航可用于 React Native 应用程序中的所有组件