mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
bug fixes
This commit is contained in:
18 files changed
+90
-72
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { omit } from 'lodash';
|
||||
import React from 'react';
|
||||
|
||||
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { childDom: HTMLElement }) {
|
||||
const [dom, setDom] = React.useState<HTMLElement | null>(null);
|
||||
React.useEffect(() => {
|
||||
if (!dom) return;
|
||||
dom.appendChild(props.childDom);
|
||||
return () => { // eslint-disable-line consistent-return
|
||||
dom.removeChild(props.childDom);
|
||||
};
|
||||
}, [dom]);
|
||||
return <div {...omit(props, 'childDom')} ref={setDom}></div>;
|
||||
}
|
||||
Reference in new issue
Block a user