You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/packages/ui-default/components/react/DomComponent.tsx

15 lines
441 B
TypeScript

import $ from 'jquery';
3 years ago
import { omit } from 'lodash';
import React from 'react';
3 years ago
export default function DomComponent(props: React.HTMLAttributes<HTMLDivElement> & { childDom: HTMLElement }) {
3 years ago
const ref = React.useRef<HTMLDivElement>();
React.useEffect(() => {
ref.current.appendChild(props.childDom);
3 years ago
return () => {
$(ref.current).empty();
};
}, []);
3 years ago
return <div {...omit(props, 'childDom')} ref={ref}></div>;
}