import React, { ForwardedRef } from 'react'; import { useForwardedRef } from '@leafygreen-ui/hooks'; import { useDarkMode } from '@leafygreen-ui/leafygreen-provider'; import { useTableContext } from '../TableContext'; import { LGRowData } from '../useLeafyGreenTable'; import InternalRowWithoutRT from './InternalRowWithoutRT'; import { MemoizedInternalRowWithRT } from './InternalRowWithRT'; import { RowComponentType, RowProps } from './Row.types'; import { RowContextProvider } from './RowContext'; /** * Renders the provided cells */ const RowWithRef = ( { row, virtualRow, disabled = false, ...rest }: RowProps, fwdRef: ForwardedRef, ) => { const { theme } = useDarkMode(); const { shouldAlternateRowColor = false, virtualTable, shouldMemoizeRows, } = useTableContext(); const ref = useForwardedRef(fwdRef, null); return ( <> {row ? ( ) : ( )} ); }; // React.forwardRef can only work with plain function types, i.e. types with a single call signature and no other members. // Asserts that `Row` is of type `RowComponentType` which works with generics export const Row = React.forwardRef(RowWithRef) as RowComponentType; Row.displayName = 'Row'; export default Row;