diff --git a/package.json b/package.json index 9781acc8..5133463e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "recyclerlistview", - "version": "2.0.8", + "version": "2.0.9", "description": "The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.", "main": "dist/reactnative/index.js", "types": "dist/reactnative/index.d.ts", diff --git a/src/core/RecyclerListView.tsx b/src/core/RecyclerListView.tsx index b514e552..cfc41cba 100644 --- a/src/core/RecyclerListView.tsx +++ b/src/core/RecyclerListView.tsx @@ -399,7 +399,8 @@ export default class RecyclerListView
= 0) { const layoutManager = this._virtualRenderer.getLayoutManager(); if (layoutManager) { - layoutManager.relayoutFromIndex(this._relayoutReqIndex, newProps.dataProvider.getSize()); + const dataProviderSize = newProps.dataProvider.getSize(); + layoutManager.relayoutFromIndex(Math.min(Math.max(dataProviderSize - 1, 0), this._relayoutReqIndex), dataProviderSize); this._relayoutReqIndex = -1; this._refreshViewability(); }