到目前为止,我一直试图修复我的代码而没有运气。这是我的问题,我非常感谢你的帮助。
1-在我的顶级索引js中,我创建了一个商店并调用store.dispatch(startListeningToAuthChanges())
2-无状态startListeningToAuthChanges定义:
export const startListeningToAuthChanges = () => {
return (dispatch) => {
// listen from Firebase
auth.onAuthStateChanged((user) => {
if (user) {
// I am already saving displayName to the store in another file and would like to read it from the store so that I can push it to Firebase. I have no idea how I can read it from the store. I tried "connect" but I keep getting undefined.
usersRef.child(user.uid).set('Need to set displayName here'));
} else {
dispatch(signedOut());
}
})
}; };