Files
Hydro/packages/ui-default/components/react/DomComponent.tsx
T
2025-04-19 16:45:37 +08:00

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>;
}