Skip to content

Instantly share code, notes, and snippets.

@mikevercoelen
Created January 30, 2018 09:07
Show Gist options
  • Save mikevercoelen/ed34f32e901e7efbc71e355d85d05b55 to your computer and use it in GitHub Desktop.
Save mikevercoelen/ed34f32e901e7efbc71e355d85d05b55 to your computer and use it in GitHub Desktop.
New purposal for routes
// Old
export const appRoutes = (
<div>
<Route path="companies/:companyId" component={CompanyNavigation} >
<IndexRoute component={CompanyProjectsContainer} /> // TODO: Dashboard?
<Route path="projects" component={CompanyProjectsContainer} />
<Route path="users" component={CompanyUsersContainer} />
<Route path="divisions" component={CompanyDivisionsContainer} />
<Route path="activities" component={CompanyActivitiesContainer} />
</Route>
<Route path="projects/:projectId" component={ProjectNavigation} >
<IndexRoute component={ProjectInfoContainer} /> // TODO: Nice view?
<Route path="info" component={ProjectInfoContainer} />
<Route path="activities" component={ProjectActivitiesContainer} />
<Route path="assets" component={ProjectAssetsContainer} />
<Route path="members" component={ProjectUsersContainer} />
<Route path="locations" component={ProjectLocationsContainer} />
<Route path="touchforms/:touchformId" component={ProjectTouchformContainer} />
<Route path="work_packages" component={ProjectWorkPackagesContainer} />
<Route path="registrations" component={ProjectRegistrationsContainer} />
<Route path="registrations/:registrationId" component={RegistrationContainer} />
<Route path="*" component={NotFound} />
</Route>
</div>
);
// New
export default (store) => ({
component: AppLayout,
childRoutes: [
Company(store),
CompanyProjects(store),
CompanyUsers(store),
{
path: '*',
indexRoute: {
onEnter: (nextState, replace) => replace(Routes.NOT_FOUND)
}
}
]
});
// All "new" routes would be a separate folder, a "page" in the folder "pages"
// With the new setup, each "page" would be lazy loaded, even the reducer for the container could be lazy loaded and injected in this way.
// With this new setup, we keep everything organized and lazy loaded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment