Skip to content

Commit

Permalink
improvement(routing): use "withStoreModule" to inject reducer dynamic…
Browse files Browse the repository at this point in the history
…ally

#improves #43
  • Loading branch information
aneurysmjs committed Oct 10, 2019
1 parent 99afdc1 commit 2d0116e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/app/components/routing/Routing.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import React, { ReactElement } from 'react';
import React, { ReactElement, ComponentType } from 'react';
import { Route } from 'react-router-dom';
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore

import loadable from '@loadable/component'; // eslint-disable-line @typescript-eslint/no-unused-vars
import Layout from '~/components/core/Layout';
import { withStoreModule } from '~/store/config/dynoStore';

// const Home = loadable(() => import(/* webpackChunkName: "Home" */'~/pages/Home/Home'));
import Layout from '~/components/core/Layout';

import Home from '~/components/pages/Home';
/**
* @des by the moment it has be like this since @loable/babel-plugin gets mad:
*
* loadable: multiple import calls inside `loadable()` function are not supported.
*
* also if we remove @loable/babel-plugin, we no longer have code-splitting for SSR
*/
const HomeModule = (): Promise<{ default: ComponentType }> =>
withStoreModule(
import(/* webpackChunkName: "Home" */ '~/components/pages/Home'),
import(/* webpackChunkName: "productsReducer" */ '~/store/modules/products/reducers'),
);

// const Loading = () => (<div>...</div>);
const Home = loadable(HomeModule);

const Routing = (): ReactElement => (
<main>
Expand Down

0 comments on commit 2d0116e

Please sign in to comment.