From 2cc049dcd2c9f6995f290a13fe7304cde7c1daef Mon Sep 17 00:00:00 2001 From: yeliex Date: Mon, 25 Aug 2025 16:16:12 +0800 Subject: [PATCH 1/3] fix: unexpected expection when style array contains undefined Currently, when the style prop is an array and contains undefined, it may throw "right operand of 'in' is not an object" for example: https://github.com/react-navigation/react-navigation/blob/main/packages/elements/src/SafeAreaProviderCompat.tsx#L36 https://github.com/expo/expo/blob/main/packages/expo-router/src/views/Unmatched.tsx#L110 --- src/runtime/native/react/rules.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/native/react/rules.ts b/src/runtime/native/react/rules.ts index 048c314..f6dead7 100644 --- a/src/runtime/native/react/rules.ts +++ b/src/runtime/native/react/rules.ts @@ -71,6 +71,10 @@ export function updateRules( if (target) { if (Array.isArray(target)) { for (const item of target) { + // undefined is allowed in style array + if (!item) { + continue; + } if (VAR_SYMBOL in item) { inlineVariables.add(item); } else if ( From ad61f3c8d855286aefbfdf93053fe2a69f3e94c2 Mon Sep 17 00:00:00 2001 From: yeliex Date: Mon, 25 Aug 2025 16:18:04 +0800 Subject: [PATCH 2/3] Update comment for style array handling Clarify comment about allowed values in style array. --- src/runtime/native/react/rules.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runtime/native/react/rules.ts b/src/runtime/native/react/rules.ts index f6dead7..5fda32e 100644 --- a/src/runtime/native/react/rules.ts +++ b/src/runtime/native/react/rules.ts @@ -71,10 +71,12 @@ export function updateRules( if (target) { if (Array.isArray(target)) { for (const item of target) { - // undefined is allowed in style array + + // undefined or falsy is allowed in the style array if (!item) { continue; } + if (VAR_SYMBOL in item) { inlineVariables.add(item); } else if ( From 6a41ae8d02297caac67ee98f4468c678a28e7d17 Mon Sep 17 00:00:00 2001 From: yeliex Date: Mon, 25 Aug 2025 16:18:42 +0800 Subject: [PATCH 3/3] Update rules.ts to handle falsy values in style array --- src/runtime/native/react/rules.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/runtime/native/react/rules.ts b/src/runtime/native/react/rules.ts index 5fda32e..1ff6c1b 100644 --- a/src/runtime/native/react/rules.ts +++ b/src/runtime/native/react/rules.ts @@ -71,7 +71,6 @@ export function updateRules( if (target) { if (Array.isArray(target)) { for (const item of target) { - // undefined or falsy is allowed in the style array if (!item) { continue;