Skip to content

Commit

Permalink
RN: Improve Error for Invalid processFilter Values (#46271)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46271

Improves the error thrown when an invalid value is supplied to `processFilter`. Without this, the error thrown would look something like:

> TypeError: … is not iterable

Changelog:
[General][Changed] - Improved error message for invalid filter values

Reviewed By: jorge-cab

Differential Revision: D62011191

fbshipit-source-id: 5594eeaf2b9174af14cc9e4daa275ae72974e597
  • Loading branch information
yungsters authored and facebook-github-bot committed Aug 30, 2024
1 parent b25d6c8 commit 4094ce0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/StyleSheet/processFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function processFilter(
}
}
}
} else {
} else if (Array.isArray(filter)) {
for (const filterFunction of filter) {
const [filterName, filterValue] = Object.entries(filterFunction)[0];
if (filterName === 'dropShadow') {
Expand All @@ -109,6 +109,8 @@ export default function processFilter(
}
}
}
} else {
throw new TypeError(`${typeof filter} filter is not a string or array`);
}

return result;
Expand Down

0 comments on commit 4094ce0

Please sign in to comment.