From 751fad151848877a16e82f0491626ebdca94f547 Mon Sep 17 00:00:00 2001 From: Mauricio Meirelles Date: Thu, 19 Oct 2023 17:39:37 +0200 Subject: [PATCH] Move shouldRefreshWithAnchoring configuration so it is possible to disable it from outside FlashList by invalidating layout. --- CHANGELOG.md | 5 +++++ src/FlashList.tsx | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7dadc7e8..757844ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [1.6.2] - 2023-10-19 + +- Move shouldRefreshWithAnchoring configuration so it is possible to disable it from outside FlashList by invalidating layout + - https://github.com/Shopify/flash-list/pull/935 + ## [1.6.1] - 2023-09-14 - Prevent an expired layout provider from being used again diff --git a/src/FlashList.tsx b/src/FlashList.tsx index 930a51f3f..462e9fd1f 100644 --- a/src/FlashList.tsx +++ b/src/FlashList.tsx @@ -173,10 +173,12 @@ class FlashList extends React.PureComponent< newState.numColumns, nextProps ); - // RLV retries to reposition the first visible item on layout provider change. - // It's not required in our case so we're disabling it - newState.layoutProvider.shouldRefreshWithAnchoring = false; } + + // RLV retries to reposition the first visible item on layout provider change. + // It's not required in our case so we're disabling it + newState.layoutProvider.shouldRefreshWithAnchoring = !!(!prevState.layoutProvider?.hasExpired); + if (nextProps.data !== prevState.data) { newState.data = nextProps.data; newState.dataProvider = prevState.dataProvider.cloneWithRows(