Skip to content

Instantly share code, notes, and snippets.

@zinevych
Created November 24, 2019 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zinevych/33ca208e8bf3ca5cf069e5258c3d0b36 to your computer and use it in GitHub Desktop.
Save zinevych/33ca208e8bf3ca5cf069e5258c3d0b36 to your computer and use it in GitHub Desktop.
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