mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
15 lines
445 B
TypeScript
15 lines
445 B
TypeScript
import $ from 'jquery';
|
|
import { omit } from 'lodash';
|
|
import React from 'react';
|
|
|
|
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { childDom: HTMLElement }) {
|
|
const ref = React.useRef<HTMLDivElement>(null);
|
|
React.useEffect(() => {
|
|
ref.current.appendChild(props.childDom);
|
|
return () => {
|
|
$(ref.current).empty();
|
|
};
|
|
}, []);
|
|
return <div {...omit(props, 'childDom')} ref={ref}></div>;
|
|
}
|