From 8d757e5ad7d46131ac573898b67708dee341419d Mon Sep 17 00:00:00 2001 From: James Reggio Date: Mon, 7 Aug 2017 22:03:43 -0700 Subject: [PATCH] Export `Animated.Node` for ease of type checking Summary: At present, there's no uniform way of determining whether you've received an Animated value node which can be attached to an animated prop. You can attempt to use `instanceof Animated.Value`, but this fails for interpolated values. You can use `instanceof Animated.Interpolation`, but this fails for the values that are returned from the math functions (e.g., `Animated.Add`). This commit exposes the base type from which all of these value nodes derive. As such, it is now possible to do the following: ```js import React, { Component, PropTypes } from 'react'; import { Animated } from 'react-native'; class Widget extends Component { static propTypes = { progress: PropTypes.instanceOf(Animated.Node).isRequired, } // ... } ``` Unnecessary for cosmetic change. Closes https://github.com/facebook/react-native/pull/14688 Differential Revision: D5581539 Pulled By: shergin fbshipit-source-id: 98f40e63a463241c7f91c72391c26c3b4153e4cd --- Libraries/Animated/src/AnimatedImplementation.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index 765044fdff..100b1382bc 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -2734,6 +2734,10 @@ module.exports = { * See also [`AnimatedInterpolation`](docs/animated.html#animatedinterpolation). */ Interpolation: AnimatedInterpolation, + /** + * Exported for ease of type checking. All animated values derive from this class. + */ + Node: Animated, /** * Animates a value from an initial velocity to zero based on a decay