Skip to content

Commit 1b3581e

Browse files
genkikondofacebook-github-bot
authored andcommitted
Export isSupportedProp checks in NativeAnimatedHelper
Summary: More convenient to call these Changelog: [Internal] - Export isSupportedProp checks in NativeAnimatedHelper Reviewed By: javache Differential Revision: D34163370 fbshipit-source-id: 9e3b5e5e4a9272f9b807863dfde2c3b0fb13acd8
1 parent cefc056 commit 1b3581e

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

Libraries/Animated/NativeAnimatedHelper.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,22 @@ function addWhitelistedInterpolationParam(param: string): void {
308308
SUPPORTED_INTERPOLATION_PARAMS[param] = true;
309309
}
310310

311+
function isSupportedColorStyleProp(prop: string): boolean {
312+
return SUPPORTED_COLOR_STYLES.hasOwnProperty(prop);
313+
}
314+
315+
function isSupportedStyleProp(prop: string): boolean {
316+
return SUPPORTED_STYLES.hasOwnProperty(prop);
317+
}
318+
319+
function isSupportedTransformProp(prop: string): boolean {
320+
return SUPPORTED_TRANSFORMS.hasOwnProperty(prop);
321+
}
322+
323+
function isSupportedInterpolationParam(param: string): boolean {
324+
return SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(param);
325+
}
326+
311327
function validateTransform(
312328
configs: Array<
313329
| {
@@ -325,7 +341,7 @@ function validateTransform(
325341
>,
326342
): void {
327343
configs.forEach(config => {
328-
if (!SUPPORTED_TRANSFORMS.hasOwnProperty(config.property)) {
344+
if (!isSupportedTransformProp(config.property)) {
329345
throw new Error(
330346
`Property '${config.property}' is not supported by native animated module`,
331347
);
@@ -335,7 +351,7 @@ function validateTransform(
335351

336352
function validateStyles(styles: {[key: string]: ?number, ...}): void {
337353
for (const key in styles) {
338-
if (!SUPPORTED_STYLES.hasOwnProperty(key)) {
354+
if (!isSupportedStyleProp(key)) {
339355
throw new Error(
340356
`Style property '${key}' is not supported by native animated module`,
341357
);
@@ -345,7 +361,7 @@ function validateStyles(styles: {[key: string]: ?number, ...}): void {
345361

346362
function validateInterpolation(config: InterpolationConfigType): void {
347363
for (const key in config) {
348-
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
364+
if (!isSupportedInterpolationParam(key)) {
349365
throw new Error(
350366
`Interpolation property '${key}' is not supported by native animated module`,
351367
);
@@ -411,10 +427,10 @@ function transformDataType(value: number | string): number | string {
411427

412428
module.exports = {
413429
API,
414-
SUPPORTED_STYLES,
415-
SUPPORTED_COLOR_STYLES,
416-
SUPPORTED_TRANSFORMS,
417-
SUPPORTED_INTERPOLATION_PARAMS,
430+
isSupportedColorStyleProp,
431+
isSupportedStyleProp,
432+
isSupportedTransformProp,
433+
isSupportedInterpolationParam,
418434
addWhitelistedStyleProp,
419435
addWhitelistedTransformProp,
420436
addWhitelistedInterpolationParam,

0 commit comments

Comments
 (0)