Remove invariant on nested sibling VirtualizedLists without unique listKey props

Summary:
It's easy to accidentally trigger this invariant when adding / moving around a component that relies on a FlatList.

There might be some unexpected behavior when this occurs, i.e. messed up virtualization / viewability logging. But to me, that is a better outcome than crashing the JS context.

Reviewed By: sahrens

Differential Revision: D14975295

fbshipit-source-id: 18015a780a153aae995723b120440be0e55d8e8b
This commit is contained in:
Logan Daniels
2019-05-01 15:10:11 -07:00
committed by Facebook Github Bot
parent b273516b02
commit af5633bcba

View File

@@ -526,12 +526,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
this._cellKeysToChildListKeys.set(childList.cellKey, childListsInCell);
const existingChildData = this._nestedChildLists.get(childList.key);
invariant(
!(existingChildData && existingChildData.ref !== null),
'A VirtualizedList contains a cell which itself contains ' +
'more than one VirtualizedList of the same orientation as the parent ' +
'list. You must pass a unique listKey prop to each sibling list.',
);
if (existingChildData && existingChildData.ref !== null) {
console.error(
'A VirtualizedList contains a cell which itself contains ' +
'more than one VirtualizedList of the same orientation as the parent ' +
'list. You must pass a unique listKey prop to each sibling list.',
);
}
this._nestedChildLists.set(childList.key, {
ref: childList.ref,
state: null,