I am using react-router-dom and and redux. I use history.push("/") after dispatching but it shows error. I want user to navigate to "/" after successfull authentication(USING GOOGLE)
export const googleLogin = () => async (dispatch) => {
try {
const response = await auth.signInWithPopup(provider);
const doc = await db.collection("users").doc(response.user.uid).get();
if (doc.exists) {
await db
.collection("users")
.doc(response.user.uid)
.set(
{
accountDetail: {
emailVerified: response.user.emailVerified,
photoURL: response.user.photoURL,
},
},
{ merge: true }
);
history.push("/")
} else {
await db
.collection("users")
.doc(response.user.uid)
.set({
accountDetail: {
userId: response.user.uid,
displayName: response.user.displayName,
email: response.user.email,
photoURL: auth.currentUser.photoURL,
accountCreatedAt: Date.now(),
},
});
history.push("/")
}
} catch (error) {
await dispatch({ type: AUTH_ERROR, payload: error.message });
}
};