'For some reason i don't know It's not working
**After register or create a user, the user will be redirected to the page but it's not working। How can I solve this?**
const [ createUserWithEmailAndPassword, user, loading, error, ] = useCreateUserWithEmailAndPassword(auth, {sendEmailVerification:true}); const navigate = useNavigate(); const location = useLocation(); const from = location.state?.from?.pathname || "/";
if (loading) {
<LoadingSpinner></LoadingSpinner>
}
useEffect(() => {
if (user) {
navigate(from, { replace: true });
}
}, [user]);
useEffect(() => {
if (error) {
setErrors({
...errors,
general: (
<div>
<p className="text-danger">{error?.message}</p>
</div>
),
});
}
}, [error]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
