问题
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