I have a horizontal flat list where each item is width:300
All I am trying to do is to get index of currently visible item.
With related to @fzyzcjy's and @Roman's answers. In react, 16.8+ you can use uscCallback
to handle the changing onViewableItemsChanged on the fly is not supported
error.
function MyComponent(props) {
const _onViewableItemsChanged = useCallback(({ viewableItems, changed }) => {
console.log("Visible items are", viewableItems);
console.log("Changed in this iteration", changed);
}, []);
const _viewabilityConfig = {
itemVisiblePercentThreshold: 50
}
return ;
}