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
This commit is contained in:
Bhavik Patel 2018-07-23 16:54:39 -07:00 committed by Facebook Github Bot
parent 3d8b83927b
commit 1a6666a116
1 changed files with 1 additions and 1 deletions

View File

@ -41,7 +41,7 @@ class FrameBasedAnimationDriver extends AnimationDriver {
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;