mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix problem page react unmount
This commit is contained in:
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();
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user