diff --git a/packages/react-native/Libraries/StyleSheet/processBoxShadow.js b/packages/react-native/Libraries/StyleSheet/processBoxShadow.js index adba8cd2ce0..dd258f18592 100644 --- a/packages/react-native/Libraries/StyleSheet/processBoxShadow.js +++ b/packages/react-native/Libraries/StyleSheet/processBoxShadow.js @@ -24,9 +24,12 @@ export type ParsedBoxShadow = { }; export default function processBoxShadow( - rawBoxShadows: $ReadOnlyArray | string, + rawBoxShadows: ?($ReadOnlyArray | string), ): Array { const result: Array = []; + if (rawBoxShadows == null) { + return result; + } const boxShadowList = typeof rawBoxShadows === 'string' diff --git a/packages/react-native/Libraries/StyleSheet/processFilter.js b/packages/react-native/Libraries/StyleSheet/processFilter.js index 1c2d3a0ef9c..f865d238d61 100644 --- a/packages/react-native/Libraries/StyleSheet/processFilter.js +++ b/packages/react-native/Libraries/StyleSheet/processFilter.js @@ -36,9 +36,13 @@ type ParsedDropShadow = { }; export default function processFilter( - filter: $ReadOnlyArray | string, + filter: ?($ReadOnlyArray | string), ): $ReadOnlyArray { let result: Array = []; + if (filter == null) { + return result; + } + if (typeof filter === 'string') { // matches on functions with args like "drop-shadow(1.5)" const regex = /([\w-]+)\(([^)]+)\)/g; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index f968fa563e6..93109e9e4ea 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -8875,7 +8875,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce inset?: boolean, }; declare export default function processBoxShadow( - rawBoxShadows: $ReadOnlyArray | string + rawBoxShadows: ?($ReadOnlyArray | string) ): Array; " `; @@ -8916,7 +8916,7 @@ type ParsedDropShadow = { color?: ColorValue, }; declare export default function processFilter( - filter: $ReadOnlyArray | string + filter: ?($ReadOnlyArray | string) ): $ReadOnlyArray; " `;