Hi, I'm facing a problem with redirect function from next/navigation. When the profile object is null and I try to access the route /my-profle, an error occurs "react-dom.development.js:11003 Uncaught Error: Rendered more hooks than during the previous render".
It worked fine when soft navigation. The error only occurs when I try hard navigation. Can anyone help me ?
/my-profle
const page = () => {
const { profile } = useAppSelector((state) => state.authReducer);
if (!profile?.accessToken) {
return redirect("/");
}
return (
<p className="mt-[10px]">
hello
</p>
);
};