react-native - 我需要使用导航抽屉刷新同一页面
问题描述
我需要在本机反应中使用导航抽屉刷新相同的屏幕。我可以在导航其他屏幕时刷新屏幕。但是我单击了相同的屏幕链接我无法得到任何响应。我是如何做到的
解决方案
您可以通过以下方式做到这一点,
在导航中添加一个参数(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.
}
推荐阅读
- lua - LUA 更改注释样式
- java - 如何在 Java 中读取包含任何 ASCII 字符的字符串?
- c# - 在 MacOS 中生成 .Net Core Soap Webservices 代理
- c++ - 向日期运算符添加天数+
- javascript - JavaScript 如何遍历 HTMLcollection 中的每个当前和未来元素?
- c++ - 在 C++ 中调用超级构造函数之前做一些事情
- java - 如何在 Java 中编写自定义原子方法?
- r - `devtools::check()` 删除日志文件
- ios - 我得到:使用未解析的标识符“randomBallNumber1”;你是说'randomBallNumber'吗?
- spring-batch - 从文件中读取并从 DB 中查询结果超过块大小和更新的相关行