mirror of
https://github.com/AmanTahiliani/PeerNotes.git
synced 2026-12-05 15:14:41 -05:00
finish login, logout, session context
This commit is contained in:
1 parent
c89b282e9a
commit
16c8e4377b
5 files changed
+121
-53
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { useEffect, useContext } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { SessionContext } from "../contexts/session";
|
||||
|
||||
export const useSessionRedirect = () => {
|
||||
const session = useContext(SessionContext);
|
||||
const navigate = useNavigate();
|
||||
// Redirect to home if session is defined
|
||||
useEffect(() => {
|
||||
if (session !== undefined) {
|
||||
navigate('/');
|
||||
}
|
||||
}, [session, navigate])
|
||||
}
|
||||
Reference in new issue
Block a user