Skip to content

Instantly share code, notes, and snippets.

@javarouka
Created June 6, 2017 15:44
Show Gist options
  • Save javarouka/b31765fe9e86efbc5fb2be905d87077e to your computer and use it in GitHub Desktop.
Save javarouka/b31765fe9e86efbc5fb2be905d87077e to your computer and use it in GitHub Desktop.
dynamic-route with react-router 4.x
import { injectReducer } from 'store/createRootReducer'
const appendReducer = (store, key, reducerModule) => {
const reducer = reducerModule.default || reducerModule;
injectReducer(store, { key, reducer });
};
// TODO: 계층형 라우팅 추가 필요
export const routes = [
{
exact: true,
path: '/',
component(store) {
appendReducer(store, 'entry', require('container/entry/reducer'));
return import('container/entry/EntryContainer');
}
},
{
path: '/inquiry/registration',
component(store) {
appendReducer(store, 'inquiry/registration', require('container/inquiry/reducer'));
return import('container/inquiry/InquiryRegistrationContainer');
}
},
{
path: '/order/member',
component(store) {
appendReducer(store, 'inquiry/member', require('container/order/reducer'));
return import('container/order/MemberOrderContainer');
}
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment