I'm having a little problem at trying to save my firebase user data into the Redux store, I have already tried a lot of waysto save the data in a my store like that:
const initialState = {
logged: null,
user: {}
};
Inside my user object I want all data from my firebase. I send the data like that:
firebase.auth().onAuthStateChanged(user => {
if (user) {
store.dispatch({
type: "USER_LOGIN",
payload: { user: { ...user.providerData[0] } }
});
} else {
store.dispatch({ type: "USER_LOGOUT" });
}
});
Why when am I trying to acces to the data need I to use this.props.user.user.displayName? With the couple of user, note that if I use only one user i receive undefined (Obviusly).