Created
November 24, 2019 22:04
-
-
Save zinevych/33ca208e8bf3ca5cf069e5258c3d0b36 to your computer and use it in GitHub Desktop.
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 React from 'react' | |
import ReactDOM from 'react-dom' | |
import singleSpaReact from 'single-spa-react' | |
import { property } from 'lodash' | |
import setPublicPath from './set-public-path.js' | |
const reactLifecycles = singleSpaReact({ | |
React, | |
ReactDOM, | |
loadRootComponent: () => import(/* webpackChunkName: "react-app" */'./App.js').then(property('default')), | |
domElementGetter, | |
}) | |
export const bootstrap = [ | |
() => { | |
return setPublicPath() | |
}, | |
reactLifecycles.bootstrap, | |
] | |
export const mount = [ | |
reactLifecycles.mount, | |
] | |
export const unmount = [ | |
reactLifecycles.unmount, | |
] | |
export const unload = [ | |
reactLifecycles.unload, | |
] | |
function domElementGetter() { | |
let el = document.getElementById("react-app"); | |
if (!el) { | |
el = document.createElement('div'); | |
el.id = 'react-app'; | |
document.body.appendChild(el); | |
} | |
return el; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment