Skip to content

Instantly share code, notes, and snippets.

@codeBelt
Last active April 22, 2019 14:45
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 codeBelt/4d11a3e5dc2a6e3b4a50934c65df25dc to your computer and use it in GitHub Desktop.
Save codeBelt/4d11a3e5dc2a6e3b4a50934c65df25dc to your computer and use it in GitHub Desktop.
CRA multiple apps
import {ComponentType} from 'react';
export default interface IAppDomId {
// Component: ComponentType<any>; // TODO: add when used with code splitting
Component: JSX.Element;
domId: string;
}
const apps: IAppDomId[] = [
{Component: <DashboardPage />, domId: 'js-Dashboard'},
{Component: <SchedulerPage />, domId: 'js-Scheduler'},
];
apps.forEach((obj: IAppDomId) => {
const element: HTMLElement | null = document.getElementById(obj.domId);
if (element) {
ReactDOM.render((
<Provider store={store}>
{obj.Component}
</Provider>
), element);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment