// we use a lazy import for better performance
export const BreadcrumbsDispatcher = import(
/* webpackMode: "lazy", webpackChunkName: "dispatchers" */
'Store/Breadcrumbs/Breadcrumbs.dispatcher'
/** @namespace Route/CategoryPage/Container/mapStateToProps */
export const mapStateToProps = (state) => {...};
/** @namespace Route/CategoryPage/Container/mapDispatchToProps */
export const mapDispatchToProps = (dispatch) => ({
updateBreadcrumbs: (breadcrumbs) => ((Object.keys(breadcrumbs).length)
? BreadcrumbsDispatcher.then( // promise to load BreadcrumbsDispatcher
({ default: dispatcher }) =>
dispatcher.updateWithCategory(breadcrumbs, dispatch)
: BreadcrumbsDispatcher.then(
({ default: dispatcher }) =>
dispatcher.update([], dispatch)
/** @namespace Route/CategoryPage/Container */
export class CategoryPageContainer extends PureComponent {
// updateBreadcrumbs will be passed as props when
// react-redux wraps the component
updateBreadcrumbs: PropTypes.func.isRequired,
this.updateBreadcrumbs();
componentDidUpdate(prevProps) {
this.updateBreadcrumbs();
updateBreadcrumbs(isUnmatchedCategory = false) {
// we can simply get the function from props and call it
const { updateBreadcrumbs, category } = this.props;
const breadcrumbs = isUnmatchedCategory ? {} : category;
updateBreadcrumbs(breadcrumbs);
export default connect(mapStateToProps, mapDispatchToProps)