내가 반응 기본/REDUX/중포 기지로 로그인 프로세스를 만들려고 노력하고있어 나는 몇 가지 문제를 가지고 파견하지 onAuthStateChanged ... 원주민/돌아 오는/중포 기지 반응 -
내가 작업을 파견 onAuthStateChanged을 구현하려고 ,하지만 내가 원하는대로 작동하지 않습니다.componentDidMount() {
firebaseAuth.onAuthStateChanged()
.then((user) => {
if (user) {
Actions.home();
} else {
Actions.login();
}
});
}
2 - 나는 REDUX-썽크에 있지만 파견하지 않고 행동으로의 구현 : - 내가 직접 내 아래처럼 내 구성 요소에 onAuthStateChanged 구현할
1 : 그것은 두 가지 경우에 작동하고
(하지만 그 다음에 액션을 보내고 올바른 경로로 리디렉션)
export const isAuthenticated =() => {
firebaseAuth.onAuthStateChanged()
.then((user) => {
if (user) {
console.log("launch.action#isAuthenticated - user already connected");
} else {
console.log("launch.action#isAuthenticated - user not connected");
}
});
}};
그리고 내가하고 싶은 것은 이것이다 (하지만 작동하지 않습니다) :
export const isAuthenticated =() => {
return (dispatch) => {
firebaseAuth.onAuthStateChanged()
.then((user) => {
console.log('user', user);
if (user) {
console.log("launch.action#isAuthenticated - user already connected");
dispatch(isUserConnected(true));
} else {
console.log("launch.action#isAuthenticated - user not connected");
dispatch(isUserNotConnected(true));
}
});
};
};
파견에 왜 효과가 없는지 누군가 설명 할 수 있습니까?
감사합니다.
내에서 살고있는 내 loginRequest입니까? – Rbar