首页 > 解决方案 > 我可以将句柄功能作为道具传递给路由器中的其他屏幕吗?

问题描述

每个人。我正在学习 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 组件中的一些状态值。

感谢您的回答。

标签: javascriptreact-native

解决方案


Actions.about({ param1: 'hello', param2: 'world' });

大约

this.props.param1//return hello

推荐阅读