Skip to content

Commit

Permalink
Export isSupportedProp checks in NativeAnimatedHelper
Browse files Browse the repository at this point in the history
Summary:
More convenient to call these

Changelog:
[Internal] - Export isSupportedProp checks in NativeAnimatedHelper

Reviewed By: javache

Differential Revision: D34163370

fbshipit-source-id: 9e3b5e5e4a9272f9b807863dfde2c3b0fb13acd8
  • Loading branch information
genkikondo authored and facebook-github-bot committed Feb 11, 2022
1 parent cefc056 commit 1b3581e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions Libraries/Animated/NativeAnimatedHelper.js
Expand Up @@ -308,6 +308,22 @@ function addWhitelistedInterpolationParam(param: string): void {
SUPPORTED_INTERPOLATION_PARAMS[param] = true;
}

function isSupportedColorStyleProp(prop: string): boolean {
return SUPPORTED_COLOR_STYLES.hasOwnProperty(prop);
}

function isSupportedStyleProp(prop: string): boolean {
return SUPPORTED_STYLES.hasOwnProperty(prop);
}

function isSupportedTransformProp(prop: string): boolean {
return SUPPORTED_TRANSFORMS.hasOwnProperty(prop);
}

function isSupportedInterpolationParam(param: string): boolean {
return SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(param);
}

function validateTransform(
configs: Array<
| {
Expand All @@ -325,7 +341,7 @@ function validateTransform(
>,
): void {
configs.forEach(config => {
if (!SUPPORTED_TRANSFORMS.hasOwnProperty(config.property)) {
if (!isSupportedTransformProp(config.property)) {
throw new Error(
`Property '${config.property}' is not supported by native animated module`,
);
Expand All @@ -335,7 +351,7 @@ function validateTransform(
function validateStyles(styles: {[key: string]: ?number, ...}): void {
for (const key in styles) {
if (!SUPPORTED_STYLES.hasOwnProperty(key)) {
if (!isSupportedStyleProp(key)) {
throw new Error(
`Style property '${key}' is not supported by native animated module`,
);
Expand All @@ -345,7 +361,7 @@ function validateStyles(styles: {[key: string]: ?number, ...}): void {
function validateInterpolation(config: InterpolationConfigType): void {
for (const key in config) {
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
if (!isSupportedInterpolationParam(key)) {
throw new Error(
`Interpolation property '${key}' is not supported by native animated module`,
);
Expand Down Expand Up @@ -411,10 +427,10 @@ function transformDataType(value: number | string): number | string {

module.exports = {
API,
SUPPORTED_STYLES,
SUPPORTED_COLOR_STYLES,
SUPPORTED_TRANSFORMS,
SUPPORTED_INTERPOLATION_PARAMS,
isSupportedColorStyleProp,
isSupportedStyleProp,
isSupportedTransformProp,
isSupportedInterpolationParam,
addWhitelistedStyleProp,
addWhitelistedTransformProp,
addWhitelistedInterpolationParam,
Expand Down

0 comments on commit 1b3581e

Please sign in to comment.