From a796ad45507d99de037d6c4bd6e55ef524bb9f62 Mon Sep 17 00:00:00 2001 From: inayat1 Date: Tue, 30 Jul 2019 09:07:22 +0530 Subject: [PATCH] relayoutReqIndex mismatches with dataProvider length (#385) --- package.json | 2 +- src/core/RecyclerListView.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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(); }