Skip to content

Instantly share code, notes, and snippets.

@yantakus
Created November 14, 2016 14:49
Show Gist options
  • Save yantakus/8f026eb455625dd9106f360f6e5f8c93 to your computer and use it in GitHub Desktop.
Save yantakus/8f026eb455625dd9106f360f6e5f8c93 to your computer and use it in GitHub Desktop.
// These are the pages you can go to.
// They are all wrapped in the App component, which should contain the navbar etc
// See http://blog.mxstbr.com/2016/01/react-apps-with-pages for more information
// about the code splitting business
import { getAsyncInjectors } from 'utils/asyncInjectors'
const errorLoading = (err) => {
console.error('Dynamic page loading failed', err) // eslint-disable-line no-console
}
const loadModule = (cb) => (componentModule) => {
cb(null, componentModule.default)
}
export default function createRoutes (store) {
// Create reusable async injectors using getAsyncInjectors factory
const { injectReducer, injectSagas } = getAsyncInjectors(store) // eslint-disable-line no-unused-vars
return [
{
path: '/',
name: 'home',
getComponent (nextState, cb) {
const importModules = Promise.all([
System.import('containers/HomePage')
])
const renderRoute = loadModule(cb)
importModules.then(([component]) => {
renderRoute(component)
})
importModules.catch(errorLoading)
}
}, {
path: '/sign-up',
name: 'sign-up',
getComponent (nextState, cb) {
const importModules = Promise.all([
System.import('containers/Auth/SignUp')
])
const renderRoute = loadModule(cb)
importModules.then(([component]) => {
renderRoute(component)
})
importModules.catch(errorLoading)
}
}, {
path: '/sign-up-step-2',
name: 'sign-up-step-2',
getComponent (nextState, cb) {
const importModules = Promise.all([
System.import('containers/Auth/SignUp/step-2')
])
const renderRoute = loadModule(cb)
importModules.then(([component]) => {
renderRoute(component)
})
importModules.catch(errorLoading)
}
}, {
path: '/sign-up-step-3',
name: 'sign-up-step-3',
getComponent (nextState, cb) {
const importModules = Promise.all([
System.import('containers/Auth/SignUp/step-3')
])
const renderRoute = loadModule(cb)
importModules.then(([component]) => {
renderRoute(component)
})
importModules.catch(errorLoading)
}
}, {
path: '/sign-up-step-4',
name: 'sign-up-step-4',
getComponent (nextState, cb) {
const importModules = Promise.all([
System.import('containers/Auth/SignUp/step-4')
])
const renderRoute = loadModule(cb)
importModules.then(([component]) => {
renderRoute(component)
})
importModules.catch(errorLoading)
}
}, {
path: '*',
name: 'notfound',
getComponent (nextState, cb) {
System.import('containers/NotFoundPage')
.then(loadModule(cb))
.catch(errorLoading)
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment