preact-scroll-viewport
preact-scroll-viewport copied to clipboard
Do keys make sense?
Let's say you have unique IDs (such as tweet ids), would it make sense to pass them (regarding performance)? Like so:
<ScrollViewport class="list" rowHeight={this.rowHeight}>
{ rows.map( row => (
<div class="row" key={row.id}>{row.entry}</div>
)) }
</ScrollViewport>
That will turn off recycling of the rows. In general that will be slower, but it might be desirable if your content really needs to be unmounted+remounted instead of updated in-place. You might find this is true when using homogenous row components that internally render extremely different content for any given row - in that case it can be cheaper to simply recreate each row when displayed, rather than trying to reuse rows from other ID's.