Last active
November 17, 2024 05:43
-
-
Save mtavkhelidze/6a54189cda2eb93373fc307857f4f202 to your computer and use it in GitHub Desktop.
A component for protection of routes, for example when using `wouter`
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 React, { type PropsWithChildren } from "react"; | |
type Props = { | |
with: () => boolean; | |
} & PropsWithChildren | |
const Protected: React.FC<Props> = props => | |
props.with() ? <>{props.children}</> : <UserLogin />; | |
// <Protected with={()-> isLoggedIn}><Profile/></Protected> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment