Last active
September 20, 2017 11:18
-
-
Save divyanshu013/af5d008c39c8f75b9bbbe72202c1fda0 to your computer and use it in GitHub Desktop.
Adding routes for the app
This file contains hidden or 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 { Route, Router } from 'react-router-dom'; | |
import Home from './Home'; | |
import Callback from './Callback'; | |
import Auth from './auth'; | |
import history from './history'; | |
const auth = new Auth(); | |
const handleAuthentication = (nextState, replace) => { | |
if (/access_token|id_token|error/.test(nextState.location.hash)) { | |
auth.handleAuthentication(); | |
} | |
} | |
const Routes = () => ( | |
<Router history={history} component={Home}> | |
<div> | |
<Route exact path="/" render={(props) => <Home auth={auth} {...props} />} /> | |
<Route path="/home" render={(props) => <Home auth={auth} {...props} />} /> | |
<Route path="/callback" render={(props) => { | |
handleAuthentication(props); | |
return <Callback {...props} /> | |
}}/> | |
</div> | |
</Router> | |
); | |
export default Routes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment