react-native - React Native Router Flux Actions.currentParams 道具
问题描述
这不是问题,更像是一个奇怪的问题。
一段时间以来,我一直在使用Actions.currentParams
props 来获取当前屏幕上的对象信息或执行诸如Actions.currentParams.backAndroidHandler()
访问我传递给 RNRF 的函数之类的事情Router
。
我在浏览线程时发现了这个技巧,但没有找到关于它的解释以及它是如何工作的。在 RNRF 的 github 上也找不到任何文档。我现在掌握的任何信息主要是基于将道具打印到控制台并从中剖析和推测答案。我想在没有关于我在代码中使用的东西的具体文档的情况下,像这样盲目地操作只会让我感到困扰。
如果您对此有任何信息,将非常感谢您提供材料阅读的链接,因为它已经困扰我好几天了!哈哈
解决方案
我在文档中找到了一些东西。
它看起来有一些相关性。希望能帮助到你。
...
onNavigationStateChange = async (prevState, currentState, action) => {
this.state = currentState;
this.prevState = prevState;
const activeState = getActiveState(this.state);
const currentScene = activeState.routeName;
this.currentParams = { ...activeState.params, ...action.params }; //Here!!
this.currentScene = currentScene;
this.prevScene = this.prevState ? getActiveState(this.prevState).routeName : null;
if (this.currentScene !== this.prevScene) {
// run onExit for old scene
this.onExitHandler(this.prevScene);
setTimeout(() => this.dispatch({
type: ActionConst.FOCUS,
routeName: this.currentScene,
params: this.currentParams,
}));
this.onEnterHandler(currentScene);
}
...
推荐阅读
- c# - 为什么不能在 ajax 中使用 beginform?
- reactjs - Axios 请求未在 componentDidMount 上触发
- reactjs - Gatsby 构建在页面重新加载后不采用反应引导大小前缀
- python - 用于在 Python 字典中搜索给定值的键的现成函数
- spring - 返回 405 MethodNotAllowed 而不是 ResponseStatusException() 中指定的
- vba - 子表单验证(数据表视图)
- reactjs - 使用 React 进行转换 - 我应该使用 TransitionGroup 吗?
- python - 机器人框架正则表达式处理返回值:无
- java - Java中是否有支持按(非唯一)值查找键的映射?
- javascript - 为什么在构造函数中的方法之前需要“this”?