首页 > 解决方案 > 我需要使用导航抽屉刷新同一页面

问题描述

我需要在本机反应中使用导航抽屉刷新相同的屏幕。我可以在导航其他屏幕时刷新屏幕。但是我单击了相同的屏幕链接我无法得到任何响应。我是如何做到的

标签: react-nativenavigationpage-refresh

解决方案


您可以通过以下方式做到这一点,

在导航中添加一个参数(isFromHome),

const navigateAction = NavigationActions.navigate({
      routeName: routeName,
      params: { isFromHome: true}
    });
    this.props.navigation.dispatch(navigateAction);

componentWillReceiveProps()然后在你的类中添加代码

例如:

componentWillReceiveProps(newProps) {
    console.log("#######", newProps.navigation.state.params.isFromHome);
    // Here you will get the parameter every time. By checking the parameter you can achieve your need.
  }

推荐阅读