Skip to content

Instantly share code, notes, and snippets.

@DavidLazic
Last active October 6, 2017 23:58
Show Gist options
  • Select an option

  • Save DavidLazic/132f4be66325c518c82820730f48cd13 to your computer and use it in GitHub Desktop.

Select an option

Save DavidLazic/132f4be66325c518c82820730f48cd13 to your computer and use it in GitHub Desktop.
React + Firebase - Persistent auth
import React, { Component } from 'react';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import App from 'containers/core/App';
import Login from 'containers/views/Login';
import Admin from 'containers/views/Admin';
import Home from 'containers/views/Home';
const publicPath = '/';
export const routeCodes = {
ROOT: publicPath,
LOGIN: `${ publicPath }login`,
ADMIN: `${ publicPath }admin`
};
const routes = (
<Route path={ publicPath } component={ App } >
<IndexRoute component={ Home } />
<Route path={ routeCodes.LOGIN } component={ Login } />
<Route path={ routeCodes.ADMIN } component={ Admin } protected />
<Route
path="*"
onEnter={ (next, replace) => replace({ pathname: routeCodes.ROOT }) }
component={ Home } />
</Route>
);
export default class Routes extends Component {
render () {
return (
<Router history={ browserHistory } routes={ routes } />
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment