I am doing this:
signInWithEmailAndPassword(auth, email, password).then(() => {
navigate('/')
}).catch((error) => {
On my routes page, I am doing this:
function LandingPageRedirect({ children }) {
if (loading) {
return <div>Loading...</div>; // Or a spinner/loader
}
if (user) {
return <>{children}</>
} else {
return (
<Navigate
to="/landing"
state={{
from: location.pathname,
}}
replace
/>
)
}
}
return (
<div>
<BrowserRouter>
<Routes>
<Route path='/' element={
<LandingPageRedirect>
<Home />
</LandingPageRedirect>
}
/>
However, after sign in I am being sent back to”/landing” rather than “/home”. How do I fix this?