Skip to content

Instantly share code, notes, and snippets.

@divyanshu013
Last active September 20, 2017 11:18
Show Gist options
  • Save divyanshu013/af5d008c39c8f75b9bbbe72202c1fda0 to your computer and use it in GitHub Desktop.
Save divyanshu013/af5d008c39c8f75b9bbbe72202c1fda0 to your computer and use it in GitHub Desktop.
Adding routes for the app
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