ui: scratchpad sidebar

This commit is contained in:
undefined committed 2022-08-01 22:56:04 +08:00
1 parent 981f8a4b9d
commit e3a5543d9f
14 files changed
+239 -65

No files matched your search

@@ -1,10 +1,15 @@
import React from 'react';
import { omit } from 'lodash';
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { childDom: HTMLElement }) {
const tempDoms = {};
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { id?: string, childDom: HTMLElement }) {
const ref = React.useRef<HTMLDivElement>();
React.useEffect(() => {
ref.current.appendChild(props.childDom);
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);
return () => {
$(ref.current).empty();
};