-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix invariant violation when nesting VirtualizedList inside ListEmpty…
…Component (#35875) Summary: Pull Request resolved: #35875 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. Changelog: [General][Fixed] - Fix invariant violation when nesting VirtualizedList inside ListEmptyComponent Reviewed By: christophpurrer Differential Revision: D42574462 fbshipit-source-id: f76fa795bf471cb8a929c2efdbd814ea51927663
- v0.78.0-rc.5
- v0.78.0-rc.4
- v0.78.0-rc.3
- v0.78.0-rc.2
- v0.78.0-rc.1
- v0.78.0-rc.0
- v0.77.1
- v0.77.0
- v0.77.0-rc.7
- v0.77.0-rc.6
- v0.77.0-rc.5
- v0.77.0-rc.4
- v0.77.0-rc.3
- v0.77.0-rc.2
- v0.77.0-rc.1
- v0.77.0-rc.0
- v0.76.7
- v0.76.6
- v0.76.5
- v0.76.4
- v0.76.3
- v0.76.2
- v0.76.1
- v0.76.0
- v0.76.0-rc.6
- v0.76.0-rc.5
- v0.76.0-rc.4
- v0.76.0-rc.3
- v0.76.0-rc.2
- v0.76.0-rc.1
- v0.76.0-rc.0
- v0.75.5
- v0.75.4
- v0.75.3
- v0.75.2
- v0.75.1
- v0.75.0
- v0.75.0-rc.7
- v0.75.0-rc.6
- v0.75.0-rc.5
- v0.75.0-rc.4
- v0.75.0-rc.3
- v0.75.0-rc.2
- v0.75.0-rc.1
- v0.75.0-rc.0
- v0.74.7
- v0.74.6
- v0.74.5
- v0.74.4
- v0.74.3
- v0.74.2
- v0.74.1
- v0.74.1-rc.0
- v0.74.0
- v0.74.0-rc.9
- v0.74.0-rc.8
- v0.74.0-rc.7
- v0.74.0-rc.6
- v0.74.0-rc.5
- v0.74.0-rc.4
- v0.74.0-rc.3
- v0.74.0-rc.2
- v0.74.0-rc.1
- v0.74.0-rc.0
- v0.73.11
- v0.73.10
- v0.73.9
- v0.73.8
- v0.73.7
- v0.73.6
- v0.73.5
- v0.73.4
- v0.73.3
- v0.73.2
- v0.73.1
- v0.73.0
- v0.73.0-rc.8
- v0.73.0-rc.7
- v0.73.0-rc.6
- v0.73.0-rc.5
- v0.73.0-rc.4
- v0.73.0-rc.3
- v0.73.0-rc.2
- v0.73.0-rc.1
- v0.73.0-rc.0
- v0.72.17
- v0.72.16
- v0.72.15
- v0.72.14
- v0.72.13
- v0.72.12
- v0.72.11
- v0.72.10
- v0.72.9
- v0.72.8
- v0.72.7
- v0.72.6
- v0.72.5
- v0.72.4
- v0.72.3
- v0.72.2
- v0.72.1
- v0.72.0
- v0.72.0-rc.6
- v0.72.0-rc.5
- v0.72.0-rc.4
- v0.72.0-rc.3
- v0.72.0-rc.2
- v0.72.0-rc.1
- v0.72.0-rc.0
- latest
1 parent
4cdc2c4
commit 1fef376
Showing
2 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -871,16 +871,19 @@ export default class VirtualizedList extends StateSafePureComponent< | |
<ListEmptyComponent /> | ||
)): any); | ||
cells.push( | ||
React.cloneElement(element, { | ||
key: '$empty', | ||
onLayout: (event: LayoutEvent) => { | ||
this._onLayoutEmpty(event); | ||
if (element.props.onLayout) { | ||
element.props.onLayout(event); | ||
} | ||
}, | ||
style: StyleSheet.compose(inversionStyle, element.props.style), | ||
}), | ||
<VirtualizedListCellContextProvider | ||
cellKey={this._getCellKey() + '-empty'} | ||
key="$empty"> | ||
{React.cloneElement(element, { | ||
onLayout: (event: LayoutEvent) => { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
NickGerleman
Author
Contributor
|
||
this._onLayoutEmpty(event); | ||
if (element.props.onLayout) { | ||
element.props.onLayout(event); | ||
} | ||
}, | ||
style: StyleSheet.compose(inversionStyle, element.props.style), | ||
})} | ||
</VirtualizedListCellContextProvider>, | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NickGerleman This is now throwing an error
"this.props" should not be accessed during state updates
when using state, setState & props inside the onLayout callback which used to work on previous versions? Is this expected?Reference