Can I pass state at the time of navigator dispatch method calling in react-native?

巧了我就是萌 提交于 2019-12-13 03:29:54

问题


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())}
/>

回答1:


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

Set dispatch function in your component

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

dispatch(){
 //your code
}


来源:https://stackoverflow.com/questions/53099422/can-i-pass-state-at-the-time-of-navigator-dispatch-method-calling-in-react-nativ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!