Skip to content

Instantly share code, notes, and snippets.

@phedkvist
Created May 27, 2019 20:02
Show Gist options
  • Save phedkvist/072b84671db5d5f8ff6a6b9d96553be0 to your computer and use it in GitHub Desktop.
Save phedkvist/072b84671db5d5f8ff6a6b9d96553be0 to your computer and use it in GitHub Desktop.
const PrivateRoute: React.ComponentType<any> = ({
component: Component,
...rest
}) => {
return (
<Route
{...rest}
render={props =>
fakeAuth.isAuthenticated ? (
<Component {...props} />
) : (
<Redirect
to={{
pathname: "/login",
state: { from: props.location }
}}
/>
)
}
/>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment