From 7555ae13d150bba387535b1ecb099cc27cb60ee7 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 8 Feb 2017 01:29:00 -0800 Subject: [PATCH] Init diffclamp node at 0 to avoid problems with NaN Summary: Some nodes have a value of NaN initially so if we assign the value of the input in the constructor it is possible we get NaN as a value and then it will break when trying to update the value. Initializing at 0 is actually fine with this node since it will get updated properly in the `update` method. **Test plan** Tested in an app that uses native animated diffclamp where I noticed the issue. Made sure this change fixed it. Closes https://github.com/facebook/react-native/pull/12279 Differential Revision: D4527866 fbshipit-source-id: add3fc0d86ffcf4ddcd01ff3251f2373eeaa2cf5 --- .../java/com/facebook/react/animated/DiffClampAnimatedNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java index 3d11792b385..bd59c807ccc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java @@ -28,7 +28,7 @@ import com.facebook.react.bridge.ReadableMap; mMin = config.getDouble("min"); mMax = config.getDouble("max"); - mValue = mLastValue = getInputNodeValue(); + mValue = mLastValue = 0; } @Override