我已经使用 Single Spa 的 registerApplication 注册了 4 个反应应用程序。当我从一个应用程序导航到另一个应用程序时,我在控制台中看到错误以及浏览器上的覆盖。
Uncaught Error: application 'app1' died in status UNMOUNTING: unmountComponentAtNode(...): Target container is not a DOM element.
这是我的 index.js 在注册的微应用中的样子:
function domElementGetter() {
return document.getElementById('app1-placeholder');
}
const reactLifecycles = singleSpaReact({
React,
ReactDOM,
rootComponent: App,
domElementGetter,
errorBoundary() {
return <div>This renders when a catastrophic error occurs</div>;
},
});
export const { bootstrap } = reactLifecycles;
export const { mount } = reactLifecycles;
export const { unmount } = reactLifecycles;
我正在使用 SystemJS 在 single-spa-config 文件中注册我的应用程序以进行导入,如下所示:
registerApplication('app1', SystemJS.import('app1'), pathPrefix('app1'));
function pathPrefix(prefix) {
return (location) => location.href.indexOf(`${location.origin}/${prefix}`) !== -1;
}
我不知道在哪里调试这个问题。请帮忙!