javascript - 我可以将句柄功能作为道具传递给路由器中的其他屏幕吗?
问题描述
每个人。我正在学习 React-native 并且遇到了一个问题。当我执行函数 Actions.about() 时,我想将句柄函数作为道具传递给路由中的其他屏幕。
下面是我的路线代码。
<Router>
<Scene key = "root">
<Scene key = "home" component = {Home} title = "Home" initial = {true} />
<Scene key = "about" component = {About} title = "About" />
<Scene key = "login" component = {Login} title = "LOG IN" />
</Scene>
</Router>
这是我的职责。
function handleConfirm(value) {
Actions.about(handleDo = this.handleDo);
}
然后我想在 Actions 组件中访问这个handleDo 。让我们假设this.handleDo用于更改 Home 组件中的一些状态值。
感谢您的回答。
解决方案
Actions.about({ param1: 'hello', param2: 'world' });
大约
this.props.param1//return hello
推荐阅读
- python - Scrapy 只获取最后一页的数据
- python - 如果行类似于 var 然后执行函数
- android - ViewHolder 视图创建时没有附加,但是有错误
- javascript - TypeError forEach 不是函数
- pytorch - 过滤pytorch张量中的行
- hsm - Thales HSM 中的 GC 和 FK 命令
- javascript - 如何根据不同的客户端更改json对象的键
- c# - 我如何在 mongodb 中对结果搜索进行排名
- php - 解析文件名,重命名文件,然后移动到另一个目录
- javascript - 在 componentDidMount 中设置状态时,React 应用程序不显示来自 api 的数据