Common Issues

View as Markdown
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:
<!-- dont do this: getGroupBy() returns a new array every time the template is checked -->
<infinite-data-source primaryKey="id" [data]="data" [groupBy]="getGroupBy()" />
Here getGroupBy() is called every time Angular checks the template, and it returns a new array every time - so the <infinite-data-source> receives a new groupBy and groups the data again, even when groupField has not changed. Inputs are compared by reference, so the same goes for a getter that builds an array or an object. An array or object literal written in the template is fine: Angular creates it again only when a value used inside it changes.
Instead, keep the value in a signal, or build it in a computed, so the same reference is passed until the value really changes:
protected readonly groupBy = signal<DataSourcePropGroupBy<Developer>>([
  { field: 'country' },
]);

// <infinite-data-source primaryKey="id" [data]="data" [(groupBy)]="groupBy" />

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 signal of a custom component that copies the cell's value, 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 destroyed and created again 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 the state it keeps on its own shows up in the wrong row.