Created
July 22, 2020 19:19
-
-
Save maxidr/affec005fd7869a66c8bb3f556f1571a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function PublicRoute({ children, ...rest }) { | |
const { auth } = rest; | |
return ( | |
<Route | |
{...rest} | |
render={() => { | |
if (!auth) return <Redirect to="/login" />; | |
return <Dashboard>{children}</Dashboard>; | |
}} | |
/> | |
); | |
} | |
// eslint-disable-next-line react/prop-types | |
function PrivateRoute({ children, ...rest }) { | |
const { setAuth, auth } = rest; | |
return ( | |
<Route | |
{...rest} | |
render={() => { | |
return ( | |
<Landing setAuth={setAuth} auth={auth}> | |
{children} | |
</Landing> | |
); | |
}} | |
/> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment