Archived
feat: Implement routing
This commit is contained in:
1 parent
297d2e50f9
commit
6734e59a1b
6 files changed
+193
-12
No files matched your search
@@ -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" />
|
||||
} />;
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user