Last active
October 30, 2019 17:23
-
-
Save GergKllai1/1a14a869faeeb87ba2c72bb998ee571b to your computer and use it in GitHub Desktop.
Restricting routes with CustomRoute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Switch } from "react-router-dom"; | |
import CustomRoute from "./CustomRoute"; | |
import MainIndex from "./MainIndex"; | |
import LoginPage from "./LoginPage"; | |
import RestrictedPage from "./RestrictedPage"; | |
import OnlyTeacher from "./OnlyTeacher"; | |
import OnlyStudent from "./OnlyStudent"; | |
export const Content = () => { | |
return ( | |
<> | |
<Switch> | |
<CustomRoute exact path="/index" component={MainIndex} /> | |
<CustomRoute | |
condition="signedIn" | |
exact | |
path="/restricted" | |
component={RestrictedPage} | |
/> | |
<CustomRoute | |
condition="teacher" | |
exact | |
path="/only-teacher" | |
component={OnlyTeacher} | |
/> | |
<CustomRoute | |
condition="student" | |
exact | |
path="/only-student" | |
component={OnlyStudent} | |
/> | |
<CustomRoute exact path="/login" component={LoginPage} /> | |
</Switch> | |
</> | |
); | |
}; | |
export default Content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment