我试图在堆栈导航器的标题中的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函数
handlelogout(state) {
console.log("in handlelogout", this.props.logout, state);
this.props.logout;
}
i am attaching the log i printed in the console
这里我将logout绑定到mapdispatchprops
function mapDispatchToProps(dispatch) {
return bindActionCreators(ReduxActions, dispatch);
}