Мне нужно передать ключ из объекта в функцию, но получается что этот ключ undefined
.
Каким образом я получаю error
: Данный объект получаю из props (with Redux), изначально error: ''
, но если при срабатывании функции catch
улавливает ошибку то уже error: {code: 'code error', message: 'message error'}
Есть у меня вот такая thunk
:
error - тот один из ключей и его значения объекта
export const loginInWithEmail = (email, password,error) => (dispatch) => {
if(error !== String){dispatch(loadingAuth(true))}
fire.auth()
.signInWithEmailAndPassword(email, password)
.then(() => dispatch(loadingAuth(false)))
.catch((error) => {
dispatch(getError(error));
});
};
А вот сама компонента:
const UserComponent = ({error}) => {
// когда устанавливаю console.log(error.code) здесь все работает и оно === 'код ошибки'
const loginIn = (e) => {
e.preventDefault();
loginInWithEmail(email, password,error.code); // когда устанавливаю console.log(error.code) здесь то === 'undefined'
};
return(
//code
)
}