import * as React from 'react'; import { Tr } from '@patternfly/react-table'; import { useMutationObserver } from '~/shared/hooks'; export type TableRowProps = { id: React.ReactText; index: number; title?: string; trKey: string; style?: object; className?: string; isExpanded?: boolean; recompute?: () => void; }; export const TableRow: React.FC> = ({ id, index, trKey, style, className, recompute, ...props }) => { const ref = React.useRef(null); useMutationObserver( (mutations) => { const hasRelevantChanges = mutations.some((mutation) => { return ( mutation.type === 'childList' || (mutation.type === 'attributes' && (mutation.attributeName === 'class' || mutation.attributeName === 'style' || mutation.attributeName === 'aria-expanded')) ); }); if (hasRelevantChanges) { recompute?.(); } }, recompute ? ref.current : null, { childList: true, subtree: true, attributes: true, attributeFilter: ['class', 'style', 'aria-expanded'], }, ); return ( ); };