From 1a6666a116fd8b9e8637956de2b41a1c315dd470 Mon Sep 17 00:00:00 2001 From: Bhavik Patel Date: Mon, 23 Jul 2018 16:54:39 -0700 Subject: [PATCH] Check if config contains a key before fetching. Default to 0 (#19808) Summary: Potential Fix to #19793 modified the code and tried to recreate the bug and was unable to. The red screen never popped up and nothing else seemed to be affected in a negative way. [ANDROID] [BUGFIX] [FrameBasedAnimationDriver.java] - Safely unwrapping ReadableMap by defaulting to 0 if key not present. Pull Request resolved: https://github.com/facebook/react-native/pull/19808 Differential Revision: D8960388 Pulled By: hramos fbshipit-source-id: 400cc0467e041dfcf2d6b1ec0b61d716c2de159f --- .../com/facebook/react/animated/FrameBasedAnimationDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java b/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java index f8fca1f9d22921..3029ef8fc1cfd8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/FrameBasedAnimationDriver.java @@ -41,7 +41,7 @@ public void resetConfig(ReadableMap config) { for (int i = 0; i < numberOfFrames; i++) { mFrames[i] = frames.getDouble(i); } - mToValue = config.getDouble("toValue"); + mToValue = config.hasKey("toValue") ? config.getDouble("toValue") : 0; mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1; mCurrentLoop = 1; mHasFinished = mIterations == 0;