Browse files

Export `Animated.Node` for ease of type checking

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:

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 #14688

Differential Revision: D5581539

Pulled By: shergin

fbshipit-source-id: 98f40e63a463241c7f91c72391c26c3b4153e4cd
  • Loading branch information...
jamesreggio authored and facebook-github-bot committed Aug 8, 2017
1 parent be3f1be commit 8d757e5ad7d46131ac573898b67708dee341419d
Showing with 4 additions and 0 deletions.
  1. +4 −0 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

0 comments on commit 8d757e5

Please sign in to comment.