see the code i navigate the path but not working its working for signup but its navigate the '/' router not navigate the pathname .
import { Link, useLocation, useNavigate } from "react-router-dom";
import useToken from "../../../hooks/useToken";
const [createUserWithEmailAndPassword, user, loading, error1] =
useCreateUserWithEmailAndPassword(auth, { sendEmailVerification: true });
let errorElement;
const [token] = useToken(user);
const navigate = useNavigate();
const location = useLocation();
const from = location.state?.from?.pathname || "/";
if (token) {
navigate(from, { replace: true });
}```
Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`Signup`). To locate the bad setState() call inside `Signup`, follow the stack trace as described in.(react_devtools_backend.js:3973 )
show the warning for the navigation but i navigate the selected path not the home or '/'