Closed
Description
What problem does this feature solve?
const Vue2ReactWrapper = (vueComponentFactory, componentName) => {
const ReactPage: React.FC = () => {
const [loading, setLoading] = useState(true);
const containerRef = useRef(null);
useEffect(() => {
let Vue = require('vue');
Vue = Vue.default || Vue;
if (containerRef.current) {
let vueInstance;
(async () => {
let vueApp = await vueComponentFactory();
vueApp = vueApp.default || vueApp;
const { createApp } = Vue;
vueInstance = createApp().mount(vueApp, containerRef.current);
// vueInstance = new Vue({
// render: h => h(vueApp),
// }).$mount(containerRef.current);
setLoading(false);
})();
return () => {
if(!vueInstance) return;
if (vueInstance.$destroy) {
vueInstance.$destroy();
} else if (vueInstance.sink) {
vueInstance.sink.renderer.unmount(vueInstance.$root.vnode);
}
}
}
}, []);
ReactPage.displayName = componentName;
return (
<div>
<div ref={containerRef} />
{loading && <span> 页面加载中 </span>}
</div>
);
}
return ReactPage;
}
我希望在 React 元素 unmount 时 ,Vue 元素也能够 unmount。
I hope in the React unmount to elements, also able to unmount to Vue elements.
but now vueInstance.$destroy is undefined...
What does the proposed API look like?
vueInstance.$destroy()
release resources,call beforeUnMount、
Metadata
Metadata
Assignees
Labels
No labels