@samitouri / QOS-React-2 / commits / 08fce6208e

Gracefully handle empty "xstyle" prop values (Part 2) (#23279)

#23190 misses if entry is undefined or null. This fixes this issue.

Luna Ruan committed Feb 11, 2022 at 14:36 UTC 08fce6208ed8bede70fa9291eac8412f20ac56b5
2 files changed +11
packages/react-devtools-shared/src/backend/StyleX/__tests__/utils-test.js
+7
@@ -54,6 +54,13 @@ describe('Stylex plugin utils', () => {
54 "sources": Array [],
55 }
56 `);
57 +
58 + expect(getStyleXData([undefined])).toMatchInlineSnapshot(`
59 + Object {
60 + "resolvedStyles": Object {},
61 + "sources": Array [],
62 + }
63 + `);
64 });
65
66 it('should support simple style objects', () => {
packages/react-devtools-shared/src/backend/StyleX/utils.js
+4
@@ -35,6 +35,10 @@ export function crawlData(
35
36 if (isArray(data)) {
37 data.forEach(entry => {
38 + if (entry == null) {
39 + return;
40 + }
41 +
42 if (isArray(entry)) {
43 crawlData(entry, sources, resolvedStyles);
44 } else {