Common Issues
As people have started using
<InfiniteTable /> we've noticed a few issues keep popping up.While we're trying to refine our API to be easier to use and understand, developers using the component still need to be aware of some design decisions and conventions used in the component.
Issue: Performance degradation because props are new on every render#
Passing new props on every render to the
<InfiniteTable /> component or to the <DataSource /> component can be a performance bottleneck:Here
groupField is a ref. The array is created again every time the component renders, so the <DataSource /> receives a new groupBy and groups the data again, even when groupField has not changed. Props are compared by reference, so the same goes for any array or object that is built in the template from reactive state.Instead, keep the value in a
ref, or build it in a computed, so the same reference is passed until the value really changes:Issue: State inside custom components rendered in cells is lost while scrolling#
When using custom rendering or custom components for columns, make sure your rendering logic doesn't have any local or transient state (a
ref created in the setup of a custom component, for example) - what a cell renders should come from the cell information, or from state that lives outside the cell.This is important because
InfiniteTable makes heavy use of virtualization, in both column cells and column headers, so custom components can and will be unmounted and re-mounted multiple times, during the virtualization process (triggered by user scrolling, sorting, filtering and a few other interactions).A component can also be kept and reused for another row - after sorting, for example - and then its local state shows up in the wrong row.