ns-listview-recycling
Installation
SKILL.md
ListView: recycling contract, template selectors, refresh
The itemLoading recycling contract
args.view is the recycled view from a row that scrolled off. Create only when it's absent; otherwise reconfigure what you're given:
import { ItemEventData, Label, ListView } from '@nativescript/core';
listView.on(ListView.itemLoadingEvent, (args: ItemEventData) => {
if (!args.view) {
args.view = new Label(); // create once per on-screen slot
}
(<Label>args.view).text = items[args.index];
});
Unconditionally assigning args.view = new Label() defeats recycling — every scroll frame allocates native views and scrolling jank follows. The handler must be a pure function of args.index: recycled views arrive with the previous row's state, so set every property you ever set, not just the ones that changed.