Я пытаюсь перейти к другому экрану при успешном выполнении моей функции аутентификации.Это подход, который я использую, но я получаю undefined is not an object
, когда я пытаюсь использовать .then()
Это мой код
login = () => {
const {username, password} = this.state
this.props.authentication(username, password).then(res => {
})
}
const mapDispatchToProps = dispatch => {
return {
authentication: (username, password) =>
dispatch(authenticationLoginEmail(username, password)),
};
};
Это мой избыточный код
export const authenticationLoginEmail = (username, password) => {
return dispatch => {
dispatch(authLoginEmailStart())
axios.post('url',{username, password})
.then(res=>{
console.log(res.data.idusers,'ID USERS');
...
dispatch(authLoginEmailSuccess(idusers, token))
return res
})
.catch(err=>{
dispatch(authLoginEmailfail(err))
console.log(err);
})
}
}
Ошибка
undefined is not an object (evaluating '_this.props.authentication(username, password).then')
спасибо за помощь