From 1e08c7329c54d1780e8ef7f81a3e3d82ebb4f32c Mon Sep 17 00:00:00 2001 From: Mauricio Meirelles Date: Fri, 20 Oct 2023 10:59:07 +0200 Subject: [PATCH] Move shouldRefreshWithAnchoring configuration so it is possible to disable it from outside FlashList by invalidating layout. (#935) --- CHANGELOG.md | 5 +++++ src/FlashList.tsx | 10 +++++++--- 2 files changed, 12 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..64748fe98 100644 --- a/src/FlashList.tsx +++ b/src/FlashList.tsx @@ -173,10 +173,14 @@ 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 = Boolean( + !prevState.layoutProvider?.hasExpired + ); + if (nextProps.data !== prevState.data) { newState.data = nextProps.data; newState.dataProvider = prevState.dataProvider.cloneWithRows(