single-spa-dojo is a helper library that helps implement single-spa registered application lifecycle functions (bootstrap, mount and unmount) for use with Dojo. Check out the single-spa-dojo github.
Installation
npm install --save single-spa-dojo
# Or
yarn add single-spa-dojo
Quickstart
Your bundler’s “entry file” should look like this, which allows your application to be downloaded as an in-browser ES module.
import { renderer } from '@dojo/framework/core/vdom';
import { v, w } from '@dojo/framework/widget-core/d';
import singleSpaDojo from 'single-spa-dojo';
import App from './app';
const dojoLifecycles = singleSpaDojo({
// required
renderer,
// required
v,
// required
w,
// required
appComponent: App,
// optional - see https://dojo.io/learn/creating-widgets/rendering-widgets#mountoptions-properties
mountOptions: {
// optional
registry: myRegistry,
// optional - one will be provided by single-spa automatically
domNode: document.getElementById('myContainer'),
// optional
sync: true
}
});
export const bootstrap = dojoLifecycles.bootstrap;
export const mount = dojoLifecycles.mount;
export const unmount = dojoLifecycles.unmount;
Options
All options are passed to single-spa-dojo via the opts
parameter when calling singleSpaDojo(opts)
. The following options are available:
renderer
(required): Therenderer
function imported from Dojo. See https://dojo.io/learn/creating-widgets/rendering-widgets#rendering-to-the-dom.v
(required): The function used to render dom elements in Dojo. Often JSX hides this function from you, but it can be found atimport { v } from '@dojo/framework/widget-core/d'
.w
(required): The function used to render dom elements in Dojo. Often JSX hides this function from you, but it can be found atimport { w } from '@dojo/framework/widget-core/d'
.appComponent
(required): The class or function for your root Dojo component.mountOptions
(optional): An object of Dojo MountOptions. Note that adomNode
will be provided by single-spa-dojo, if one is not provided.
当前内容版权归 single-spa 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 single-spa .