ui: fix problem page react unmount

This commit is contained in:
undefined committed 2022-08-27 18:57:56 +08:00
1 parent e2415a75c3
commit 35b0463173
6 files changed
+9 -16

No files matched your search

@@ -2,15 +2,10 @@ import $ from 'jquery';
import { omit } from 'lodash';
import React from 'react';
const tempDoms = {};
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { id?: string, childDom: HTMLElement }) {
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { childDom: HTMLElement }) {
const ref = React.useRef<HTMLDivElement>();
React.useEffect(() => {
let dom = props.childDom;
if (props.id && dom) tempDoms[props.id] = dom;
else if (props.id && !dom && tempDoms[props.id]) dom = tempDoms[props.id];
ref.current.appendChild(dom);
ref.current.appendChild(props.childDom);
return () => {
$(ref.current).empty();
};