Skip to content

Instantly share code, notes, and snippets.

@sagiavinash
Last active August 10, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagiavinash/e4980549658301db526ae9cdd4e6e3d2 to your computer and use it in GitHub Desktop.
Save sagiavinash/e4980549658301db526ae9cdd4e6e3d2 to your computer and use it in GitHub Desktop.
// HomePageContainer.js
import storeManager from 'react-store-manager';
import homeReducer from './homeReducer';
storeManager.registerReducers({ home: homeReducer });
export default connect(/* mapStateToProps, mapDispatchToProps */)(Page);
// ProductListPageContainer.js
import storeManager from 'react-store-manager';
import productListReducer from './productListReducer';
storeManager.registerReducers({ productList: productListReducer });
export default connect(/* mapStateToProps, mapDispatchToProps */)(ProductListPage);
// AppContainer.js
import storeManager from 'react-store-manager';
const HomeRoute = Loadable({
loader: import('./HomePageContainer'),
loading: () => <div>Loading...</div>
});
const ProductListRoute = Loadable({
loader: import('./ProductListPageContainer'),
loading: () => <div>Loading...</div>
});
function AppContainer({login}) {
return (
<App login={login}>
<Switch>
<Route exact path="/" component={HomeRoute} />
<Route exact path="/products" component={ProductListRoute} />
</Switch>
</App>
);
}
export default connect(/* mapStateToProps, mapDispatchToProps */)(AppContainer);
// Root.js
import storeManager from 'react-store-manager';
import AppContainer from './AppContainer';
export default function Root() {
return (
<Provider store={storeManager.createStore(/* initialState, enhancer */)}>
<AppContainer />
</Provider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment