Last active
April 22, 2019 14:45
-
-
Save codeBelt/4d11a3e5dc2a6e3b4a50934c65df25dc to your computer and use it in GitHub Desktop.
CRA multiple apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ComponentType} from 'react'; | |
export default interface IAppDomId { | |
// Component: ComponentType<any>; // TODO: add when used with code splitting | |
Component: JSX.Element; | |
domId: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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