Skip to content

Fix invariant violation when nesting VirtualizedList inside ListEmptyComponent - #35875

Closed
NickGerleman wants to merge 1 commit into
react:mainfrom
NickGerleman:export-D42574462
Closed

Fix invariant violation when nesting VirtualizedList inside ListEmptyComponent#35875
NickGerleman wants to merge 1 commit into
react:mainfrom
NickGerleman:export-D42574462

Conversation

@NickGerleman

Copy link
Copy Markdown
Contributor

Summary:
Fixes#35871

Nested VirtualizedLists register to their parents for updates, associated to a specfific cellKey set by VirtualizedListCellContextProvider. This cellKey is usually set when rendering a cell for a data item, but we can also render a nested VirtualizedList by putting one in a ListHeaderComponent/ListFooterComponent/ListEmptyComponent.

D6603342 (a010a0c) added cellKeys when we render from a header/footer, but not ListEmptyComponent, so that association would silently fail earlier.

D39466677 (010da67) added extra invariants to child list handling, that are now triggered by this case, complaining because we are trying to unregister a child list we never successfully registered, due to a missing cellKey.

This fixes the issue by providing a cellKey for ListEmptyComponent as well. It also cleans up some of the parameterization needed from when we had two VirtualizedList implementations.

Changelog:
[General][Fixed] - Fix invariant violation when nesting VirtualizedList inside ListEmptyComponent

Differential Revision: D42574462

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Jan 18, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D42574462

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D42574462

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D42574462

…Component (react#35875)
Summary:
Pull Request resolved: react#35875Fixesreact#35871
Nested VirtualizedLists register to their parents for updates, associated to a specfific cellKey set by VirtualizedListCellContextProvider. This cellKey is usually set when rendering a cell for a data item, but we can also render a nested VirtualizedList by putting one in a ListHeaderComponent/ListFooterComponent/ListEmptyComponent.
D6603342 (react@a010a0c) added cellKeys when we render from a header/footer, but not ListEmptyComponent, so that association would silently fail earlier.
D39466677 (react@010da67) added extra invariants to child list handling, that are now triggered by this case, complaining because we are trying to unregister a child list we never successfully registered, due to a missing cellKey.
This fixes the issue by providing a cellKey for ListEmptyComponent as well.
Changelog:
[General][Fixed] - Fix invariant violation when nesting VirtualizedList inside ListEmptyComponent
Differential Revision: D42574462
fbshipit-source-id: 99b51f891737eeb8b3b58b94aa6d4fd04a35d12d
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D42574462

@analysis-bot

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a8,465,327-130
androidhermesarmeabi-v7a7,785,935-135
androidhermesx868,938,872-136
androidhermesx86_648,796,830-148
androidjscarm64-v8a9,650,645-9
androidjscarmeabi-v7a8,385,131+2
androidjscx869,712,854+7
androidjscx86_6410,190,026-5

Base commit: 473eb1d
Branch: main

@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label Jan 19, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 1fef376.

kelset pushed a commit that referenced this pull request Jan 30, 2023
…Component (#35875)
Summary:
Pull Request resolved: #35875Fixes#35871
Nested VirtualizedLists register to their parents for updates, associated to a specfific cellKey set by VirtualizedListCellContextProvider. This cellKey is usually set when rendering a cell for a data item, but we can also render a nested VirtualizedList by putting one in a ListHeaderComponent/ListFooterComponent/ListEmptyComponent.
D6603342 (a010a0c) added cellKeys when we render from a header/footer, but not ListEmptyComponent, so that association would silently fail earlier.
D39466677 (010da67) added extra invariants to child list handling, that are now triggered by this case, complaining because we are trying to unregister a child list we never successfully registered, due to a missing cellKey.
This fixes the issue by providing a cellKey for ListEmptyComponent as well.
Changelog:
[General][Fixed] - Fix invariant violation when nesting VirtualizedList inside ListEmptyComponent
Reviewed By: christophpurrer
Differential Revision: D42574462
fbshipit-source-id: f76fa795bf471cb8a929c2efdbd814ea51927663
# Conflicts:
#	Libraries/Lists/VirtualizedList.js
@cipolleschicipolleschi mentioned this pull request Oct 11, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugCLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.fb-exportedMergedThis PR has been merged.p: FacebookPartner: FacebookPartner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Trying to remove non-present child list" error occurred with specific use-case

4 participants

@NickGerleman@facebook-github-bot@analysis-bot@react-native-bot