in src/data-table/data-table.tsx [134:182]
function compareCellPlacement(prevProps, nextProps) {
// header cells are not rendered through this component
if (prevProps.rowIndex === 0) {
return true;
}
if (
prevProps.data.columns !== nextProps.data.columns ||
prevProps.data.rows !== nextProps.data.rows ||
prevProps.style !== nextProps.style
) {
return false;
}
if (
prevProps.data.isSelectable === nextProps.data.isSelectable &&
prevProps.data.columnHighlightIndex === nextProps.data.columnHighlightIndex &&
prevProps.data.rowHighlightIndex === nextProps.data.rowHighlightIndex &&
prevProps.data.textQuery === nextProps.data.textQuery &&
prevProps.data.isRowSelected === nextProps.data.isRowSelected
) {
return true;
}
// at this point we know that the rowHighlightIndex or the columnHighlightIndex has changed.
// row does not need to re-render if not transitioning _from_ or _to_ highlighted
// also ensures that all cells are invalidated on column-header hover
if (
prevProps.rowIndex !== prevProps.data.rowHighlightIndex &&
prevProps.rowIndex !== nextProps.data.rowHighlightIndex &&
prevProps.data.columnHighlightIndex === nextProps.data.columnHighlightIndex &&
prevProps.data.isRowSelected === nextProps.data.isRowSelected
) {
return true;
}
// similar to the row highlight optimization, do not update the cell if not in the previously
// highlighted column or next highlighted.
if (
prevProps.columnIndex !== prevProps.data.columnHighlightIndex &&
prevProps.columnIndex !== nextProps.data.columnHighlightIndex &&
prevProps.data.rowHighlightIndex === nextProps.data.rowHighlightIndex &&
prevProps.data.isRowSelected === nextProps.data.isRowSelected
) {
return true;
}
return false;
}