/AuthGuard.jsx Secret
Created
March 25, 2022 14:42
eCommerce Platform AuthGuard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Navigate } from 'react-router-dom' | |
const AuthGuard = ({ user, children, redirectPath = '/signin' }) => { | |
if (!user) { | |
return <Navigate to={redirectPath} replace /> | |
} | |
return children | |
} | |
export default AuthGuard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment