Temporary Fix When Element Is Null

Summary:
a bug found while trying to use multiple selector on Wilde. The data returned from specific call is not in the form that we expect. This caused an exception on layout plugin when using the selector

Specifically in WIlde, when we try to get data from node by calling client side to return it, sometimes the node has been invalidated or not saved. Hence, data returned are null or undefined. However, in previous implementation, this didn't take into consideration because we assumed that we always got correct data from client.

Reviewed By: mweststrate

Differential Revision: D21410989

fbshipit-source-id: 5135578606678973b504c9be897cb48fca547555
This commit is contained in:
Chaiwat Ekkaewnumchai
2020-05-07 06:16:12 -07:00
committed by Facebook GitHub Bot
parent f4c209bc1c
commit 5ccc392135

View File

@@ -517,9 +517,13 @@ export class Elements extends PureComponent<ElementsProps, ElementsState> {
} else { } else {
const virtualRoots: Set<string> = new Set(); const virtualRoots: Set<string> = new Set();
Object.keys(props.elements).forEach((id) => virtualRoots.add(id)); Object.keys(props.elements).forEach((id) => virtualRoots.add(id));
Object.values(props.elements).forEach((element) => for (const [currentId, element] of Object.entries(props.elements)) {
element.children.forEach((id) => virtualRoots.delete(id)), if (!element) {
); virtualRoots.delete(currentId);
} else {
element.children.forEach((id) => virtualRoots.delete(id));
}
}
virtualRoots.forEach((id) => seed(id, 1)); virtualRoots.forEach((id) => seed(id, 1));
} }