This following code is trying to verify something then need to redirect to homepage.
const EmailLink = () => {
const testEmailAuth = () => {
if (firebase.auth().isSignInWithEmailLink(window.location.href)) {
if (!email) {
return null;
}
firebase
.auth()
.signInWithEmailLink(email, window.location.href)
.then(function(result) {
window.location.href = '/';
// <Redirect to="/"/>
})
.catch(function(error) {
console.log('error ' + error);
});
}
};
return (
<div className="EmailLink">
{testEmailAuth()}
</div>
);
};
I am trying to redirect with Redirect from react-router-dom.
Its not working.
Its is working with window.location.href = '/'.
Can I know why? & how to make things works with redirect
<Switch>
<Route path="/finishedSignUp" component={EmailLink}/>
</Switch>
export default withRouter(RootComponent);