techniq / mui-table

Improved Material-UI table
https://techniq.github.io/mui-table/
MIT License
45 stars 12 forks source link

Consider opting in to tracking hoveredColumn/hoveredRowData #23

Closed techniq closed 6 years ago

techniq commented 6 years ago

Currently we always wire up onMouseEnter/onMouseLeave on all [cells (https://github.com/techniq/mui-table/blob/master/src/index.js#L140) to track hoveredColumn/hoveredRowData which is used for isCellHovered along with cellProps/headerCellProps/bodyCellProps.

This can be very expensive to always trigger setState this often, especially if not using one of these methods (and isCellHovered is not required for row hovering now since we can use CSS and :hover.

While we could disable the onMouseEnter/onMouseLeave ourselves...

cellProps={{
  onMouseEnter: () => {},
  onMouseLeave: () => {}
}}

maybe this should be an opt-in behavior instead (trackHovered prop or something). Initially I thought this could be done only if isCellHovered was set, but since these are also passed to the cellProps I don't know if it would make sense to require isCellHovered as well.