What do you want to save?
Add Code snippet
New code examples
-
TypeScript 2022-02-03 00:00:26
react protected routes typescript
/*SM*/ /*example implemented with and FC and Typescript*/ import { Redirect, Route, RouteProps } from 'react-router'; export type ProtectedRouteProps = { isAuthenticated: boolean; authenticationPath: string; } & RouteProps; export default functi... Add solution -
Javascript 2021-11-21 11:56:38
how to redirect react router from the app components
import React from 'react' import { Redirect } from 'react-router-dom' const ProtectedComponent = () => { if (authFails) return <Redirect to='/login' /> } return <div> My Protected Component </div> } Add solution