From 08246b77dffa90c738c30d69e6c67c37b74e5c03 Mon Sep 17 00:00:00 2001 From: Alex Akers Date: Tue, 5 May 2015 07:16:53 -0700 Subject: [PATCH] [React Native] Fix immediate animation crash --- Libraries/Animation/AnimationUtils.js | 6 ++++-- Libraries/Animation/RCTAnimationExperimentalManager.m | 2 +- React/Base/RCTConvert.m | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Libraries/Animation/AnimationUtils.js b/Libraries/Animation/AnimationUtils.js index ac62465a0..2ee2d8a70 100644 --- a/Libraries/Animation/AnimationUtils.js +++ b/Libraries/Animation/AnimationUtils.js @@ -231,8 +231,10 @@ module.exports = { var tickCount = Math.round(duration * ticksPerSecond / 1000); var samples = []; - for (var i = 0; i <= tickCount; i++) { - samples.push(easing.call(defaults, i / tickCount)); + if (tickCount > 0) { + for (var i = 0; i <= tickCount; i++) { + samples.push(easing.call(defaults, i / tickCount)); + } } return samples; diff --git a/Libraries/Animation/RCTAnimationExperimentalManager.m b/Libraries/Animation/RCTAnimationExperimentalManager.m index 64ee577fe..6bcda39ae 100644 --- a/Libraries/Animation/RCTAnimationExperimentalManager.m +++ b/Libraries/Animation/RCTAnimationExperimentalManager.m @@ -114,7 +114,7 @@ RCT_EXPORT_METHOD(startAnimation:(NSNumber *)reactTag animationTag:(NSNumber *)animationTag duration:(NSTimeInterval)duration delay:(NSTimeInterval)delay - easingSample:(NSArray *)easingSample + easingSample:(NSNumberArray *)easingSample properties:(NSDictionary *)properties callback:(RCTResponseSenderBlock)callback) { diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index a5d2239af..9c27b95d9 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -805,7 +805,9 @@ NSArray *RCTConvertArrayValue(SEL type, id json) for (NSInteger i = 0; i < idx; i++) { [(NSMutableArray *)values addObject:json[i]]; } - [(NSMutableArray *)values addObject:value]; + if (value) { + [(NSMutableArray *)values addObject:value]; + } copy = YES; } }];