better optimizeForInsertDeleteAnimations and fix stableId collision #479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR try to prevent RLV recycler too hard.
I try to use RLV and react-native-reanimated (Transitioning.View) for cool list animation (fade in, fade out, move)
But original RLV with optimizeForInsertDeleteAnimations not help 100%
When new item with new stableId come in.
Sometimes, RLV try to recycle with old render key so animation is Transition.Change, not Transition.In
So, my core idea. every time dataSource change. I will clear recyclePool. It will prevent reuse old render key,
new item will mount in (not update). It also help stableId collision.
DataProvider.cloneWithRows with 3rd optinal parameter optimizeForInsertAtBottomAnimation = true will try to _requiresDataChangeHandling when dataSource have something new item added to bottom of RLV (load more)
So _requiresDataChangeHandling = true will trigger VirtualRenderer.handleDataSetChange and prevent recycle items at top of RLV (Prevent top down move animation).
Now i'm happy with RLV and react-native-reanimated and goodbye Flatlist :)