Skip to content

Commit

Permalink
Export Animated.Node for ease of type checking
Browse files Browse the repository at this point in the history
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 #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 8d757e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Libraries/Animated/src/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8d757e5

Please sign in to comment.