Skip to content
Browse files

Properly validate layout animation config

The type key for a layout animation config must be supplied otherwise the app crashes (on Android). I added a isRequired check in JS as well as an explicit exception in java otherwise it crashed at a very hard to debug place. The crash happens when passing null to `Animation.setInterpolator` so this makes sure it never happens.

**Test plan (required)**

Tested that the error is caught properly in JS when passing an invalid animation config like

  duration: 250,
   update: { type: undefined }, // or LayoutAnimation.Types.easeInEastOut in my case haha :)

Also tested the java exception.
Closes #7958

Differential Revision: D3401760

Pulled By: nicklockwood

fbshipit-source-id: 83c019d863c2b2294405b60e87297c562add0f49
  • Loading branch information
janicduplessis authored and Facebook Github Bot 5 committed Jun 7, 2016
1 parent 0e50373 commit d4e7c8a0550891208284bd1d900bd9721d899f8f
@@ -40,7 +40,7 @@ var animChecker = createStrictShapeTypeChecker({
initialVelocity: PropTypes.number,
type: PropTypes.oneOf(
property: PropTypes.oneOf( // Only applies to create/delete
@@ -61,8 +61,10 @@ public void initializeFromConfig(ReadableMap data, int globalDuration) {
AnimatedPropertyType.fromString(data.getString("property")) : null;
mDurationMs = data.hasKey("duration") ? data.getInt("duration") : globalDuration;
mDelayMs = data.hasKey("delay") ? data.getInt("delay") : 0;
mInterpolator = data.hasKey("type") ?
getInterpolator(InterpolatorType.fromString(data.getString("type"))) : null;
if (!data.hasKey("type")) {
throw new IllegalArgumentException("Missing interpolation type.");
mInterpolator = getInterpolator(InterpolatorType.fromString(data.getString("type")));

if (!isValid()) {
throw new IllegalViewOperationException("Invalid layout animation : " + data);

0 comments on commit d4e7c8a

Please sign in to comment.
You can’t perform that action at this time.