我可以在react-native调用导航器分派方法时传递状态吗? [英] Can I pass state at the time of navigator dispatch method calling in react-native?

查看:341
本文介绍了我可以在react-native调用导航器分派方法时传递状态吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在调度动作调用时在抽屉式菜单/导航器上传递一个状态.

I want to pass a state on drawer menu/navigator at the time of dispatch action calling.

<Button
title='Filter'
onPress={() => navigation.dispatch(DrawerActions.openDrawer())}
/>

推荐答案

您应该调用调度函数,并使用this.props.navigation.setParams设置何时安装组件.

You should call your dispatch function and set when your component is mounted using this.props.navigation.setParams

在组件中设置调度功能

this.props.navigation.setParams({
   dispatch: this.dispatch.bind(this)
})

dispatch(){
 //your code
}

这篇关于我可以在react-native调用导航器分派方法时传递状态吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆