Probably a basic question since I'm new to to fron...
# javascript
h
Probably a basic question since I'm new to to frontend dev and not supabase specific, I'm using react router with a
<RequireAuth>
(navigates to
/login
if not logged in) component for my routes. My goal is that when a user logs out, they get sent to
"/"
. What actually happens is user is first navigated to
/login
and then to
/
.
here's the require auth component
Copy code
export const RequireAuth = ({ children }: { children: JSX.Element}) => {
    let auth = useContext(AuthContext)
    let location = useLocation()

    if (!auth.user) {
        return <Navigate to={"/login"} state={{ from: location }} replace />
    }
    return children
}
and here's signout
Copy code
let signout = async (callback: VoidFunction) => {
        let {error} = await client.auth.signOut()
        if (error) console.log("Error: ", error.message)
        callback()
    }
the callback is literally
() => {navigate("/")}