I have a loader function ProfileLoader() in the /profile route. As of my understanding of loaders, when I click on the Profile button on my website, the ProfileLoader() function runs, and after that it redirects to /profilepage. But I am not being redirected to the /login page if I'm not logged in. But the console.log("User is not logged in") is getting printed in the console. The login and logout functionality works well. But the redirect() is not working as expected.
Also why do I need to return <Outlet />; in ProfileLoader.jsx at the bottom. Removing that shows the <NotFound404 /> element. As far as I know, <Outlet /> is used to tell the parent route where to render the children route. But I am not able to understand why return <Outlet />; is used in ProfileLoader.jsx.