Spaces:
Running
Running
Download src/components/Shared/PublicRoute.jsx from STAR-GROUP/model-test-react: direct link, hf CLI and curl.
- Browser
- Download file 391 Bytes
-
https://huggingface.co/spaces/STAR-GROUP/model-test-react/resolve/main/src/components/Shared/PublicRoute.jsx
- Command line
-
hf download hf://spaces/STAR-GROUP/model-test-react/src/components/Shared/PublicRoute.jsx
-
curl -L -o PublicRoute.jsx https://huggingface.co/spaces/STAR-GROUP/model-test-react/resolve/main/src/components/Shared/PublicRoute.jsx
391 Bytes
| import React from "react"; | |
| import { Navigate } from "react-router-dom"; | |
| import { useAuth } from "../../context/AuthContext"; | |
| const PublicRoute = ({ children }) => { | |
| const { authenticated } = useAuth(); | |
| // Redirect authenticated users away from public routes | |
| if (authenticated) { | |
| return <Navigate to="/" />; | |
| } | |
| return children; | |
| }; | |
| export default PublicRoute; | |