Skip to content

Instantly share code, notes, and snippets.

@maxidr
Created July 22, 2020 19:19
Show Gist options
  • Save maxidr/affec005fd7869a66c8bb3f556f1571a to your computer and use it in GitHub Desktop.
Save maxidr/affec005fd7869a66c8bb3f556f1571a to your computer and use it in GitHub Desktop.
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