Tried to add a Protected Route for the Home page

This commit is contained in:
2024-05-24 10:28:26 +08:00
parent c74d559499
commit fbe380c771

View File

@@ -0,0 +1,19 @@
import { Navigate } from "react-router-dom"
import React from "react"
import Root from "../routes/Root"
export default function ProtectedRoute({ user, loading }) {
return (
<>
{!loading ? (
user ? (
<Root />
) : (
<Navigate to="/login" />
)
) : (
<div>loading....</div>
)}
</>
)
}