Last active
February 1, 2017 17:09
-
-
Save kwelch/54b7c658a4fc4165a557be0c398e6b20 to your computer and use it in GitHub Desktop.
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, { Component } from 'react'; | |
import { Provider } from 'react-redux'; | |
import { BrowserRouter as Router, Match, Miss }from 'react-router'; | |
import AuthenticatedMatch from '../AuthenticatedMatch'; | |
import styles from './App.scss'; | |
import Header from './Header'; | |
import Footer from './Footer'; | |
import configureStore from '../../store/configureStore'; | |
import RoleActions from '../../actions/roles'; | |
const components = { | |
loginView: require('../LoginView').default, | |
pageNotFoundView: require('./PageNotFound').default, | |
homePage: require('../HomePage').default, | |
adminLayout: require.ensure([], function (require) { | |
return require('../Admin').default; | |
}, 'admin'), | |
podsLayout: require('../Pods').default, | |
}; | |
const store = configureStore(); | |
// on app start load roles | |
store.dispatch(RoleActions.get()); | |
export default class App extends Component { | |
render() { | |
return ( | |
<Provider store={store}> | |
<Router> | |
<div className={styles.container}> | |
<Header className={styles.header} /> | |
<div className={styles.content}> | |
<Match exactly pattern="/" component={components.homePage} /> | |
<Match exactly pattern="(/login)?" component={components.loginView} /> | |
<AuthenticatedMatch pattern="/admin" roles={["Admin", "Supervisor"]} component={components.adminLayout} /> | |
<AuthenticatedMatch pattern="/pods" component={components.podsLayout} /> | |
<Miss component={components.homePage} /> | |
</div> | |
<Footer className={styles.footer} /> | |
</div> | |
</Router> | |
</Provider> | |
); | |
} | |
} |
Thank you! I'll try to reproduce in my code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code splitting is only on adminLayout(line:16)