File size: 245 Bytes
cca35ea
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
import { Navigate } from 'react-router-dom'
import { useAuth } from '../hooks/useAuth'

export default function ProtectedRoute({ children }) {
  const { user } = useAuth()
  if (!user) return <Navigate to="/login" replace />
  return children
}