Skip to content

Commit

Permalink
Remove invariant on nested sibling VirtualizedLists without unique li…
Browse files Browse the repository at this point in the history
…stKey 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
  • Loading branch information
logandaniels authored and facebook-github-bot committed May 1, 2019
1 parent b273516 commit af5633b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit af5633b

Please sign in to comment.