1import * as React from "react";
2import { Route } from "react-router-dom";
3
4interface IProps {
5 exact?: boolean;
6 path: string;
7 component: React.ComponentType<any>;
8}
9
10const LoggedOutRoute = ({
11 component: Component,
12 ...otherProps
13}: IProps) => (
14 <>
15 <header>Logged Out Header</header>
16 <Route
17 render={otherProps => (
18 <>
19 <Component {...otherProps} />
20 </>
21 )}
22 />
23 <footer>Logged Out Footer</footer>
24 </>
25);
26
27export default LoggedOutRoute;
28
1import React from "react";
2import { Route, Redirect } from "react-router-dom";
3
4const PrivateRoute: React.FC<{
5 component: React.FC;
6 path: string;
7 exact: boolean;
8 }> = (props) => {
9
10 const condition = performValidationHere();
11
12 return condition ? (<Route path={props.path} exact={props.exact} component={props.component} />) :
13 (<Redirect to="/page/login" />);
14};
15export default PrivateRoute;
16