feat: Implement routing

This commit is contained in:
Alexander Polynomdivision
2018-08-26 16:23:48 +02:00
parent 297d2e50f9
commit 6734e59a1b
6 changed files with 193 additions and 12 deletions

View File

@@ -0,0 +1,18 @@
import * as React from "react";
import { Route, Redirect } from "react-router-dom";
interface IAuthRouteProps {
path: string;
component: any;
isAuth: () => boolean;
}
export default class AuthRoute extends React.Component<IAuthRouteProps, {}> {
render() {
const auth = this.props.isAuth();
return <Route path={this.props.path} component={
() => auth ? <this.props.component /> : <Redirect to="/login" />
} />;
}
};