我需要刷新同一页面使用导航抽屉

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

我需要刷新相同的屏幕使用导航抽屉反应native.I可以刷导屏幕导航其他屏幕。但我点击相同的屏幕链接我无法得到任何响应。我怎么做

react-native navigation page-refresh
1个回答
0
投票

你可以通过以下方式做到

在导航中添加一个参数(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.
  }
© www.soinside.com 2019 - 2024. All rights reserved.