我正在尝试在堆栈导航器标题中的按钮 onPress 中调用 handlelogout(),然后在 handlelogout() 中调用this.props.logout
操作,该操作将调用导航减速器以重置到登录屏幕.....但this.props.logout
没有调用一个动作....什么也没发生
static navigationOptions = ({ navigation }) => {
const { params } = navigation.state;
console.log("navigation", navigation);
return {
title: "Profile List",
gesturesEnabled: false,
headerLeft: null,
headerRight: <Button title={"Logout"} onPress={() => params.handlelogout && params.handlelogout({ state: navigation.state })} />
}
};
这是我的句柄注销功能
handlelogout(state) {
console.log("in handlelogout", this.props.logout, state);
this.props.logout;
}
在这里,我将注销绑定到 mapdispatchprops
function mapDispatchToProps(dispatch) {
return bindActionCreators(ReduxActions, dispatch);
}