I have encountered an issue with my React app, I'm trying to create private routes. However, when the I try to pass the status of the user (Authenticated or not //true or false), I get the following error :
Type '{ IsAuthenticated: boolean; }' is not assignable to type 'IntrinsicAttributes & boolean'.ts(2322)
Here's my code :
export default function App ():ReactElement {
const params = useParams()
const [IsAuthenticated, setAuthenticated] = useState(Boolean)
axios.get(`${process.env.API_URL || 'http:///localhost'}:${process.env.API_PORT || 8000}/api/session`)
.then(res => {
console.log(res.data.IsAuthenticated)
if (res.data.IsAuthenticated) return setAuthenticated(false)
else return setAuthenticated(false)
})
return (
<Router>
<Routes>
<Route path='/' element={<Home/>}/>
<Route path='/' element={<ProtectedRoute IsAuthenticated={IsAuthenticated}/>}>
<Route path="dashboard" element={<Main/>}/>
<Route path='user/:userId' element={<Userdetail userId={params}/>}/>
</Route>
<Route
path="*"
element={<Navigate to="/" replace />}
/>
</Routes>
</Router>
)
}```