Skip to content

Commit

Permalink
Gracefully handle empty "xstyle" prop values (Part 2) (#23279)
Browse files Browse the repository at this point in the history
#23190 misses if entry is undefined or null. This fixes this issue.
  • Loading branch information
lunaruan authored Feb 11, 2022
1 parent 1fb0d06 commit 08fce62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ describe('Stylex plugin utils', () => {
"sources": Array [],
}
`);

expect(getStyleXData([undefined])).toMatchInlineSnapshot(`
Object {
"resolvedStyles": Object {},
"sources": Array [],
}
`);
});

it('should support simple style objects', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/react-devtools-shared/src/backend/StyleX/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export function crawlData(

if (isArray(data)) {
data.forEach(entry => {
if (entry == null) {
return;
}

if (isArray(entry)) {
crawlData(entry, sources, resolvedStyles);
} else {
Expand Down

0 comments on commit 08fce62

Please sign in to comment.