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