Skip to content

Commit

Permalink
Expose getNode() on component created with createAnimatedComponent
Browse files Browse the repository at this point in the history
Summary:
see also: eb3360b#commitcomment-19042340

commit eb3360b recently break some third libraries that was (weakly) relying on traversing `animatedNode.refs.node` to get the original node of the decorated (animated) component (at least 2 libs: gl-react-native and react-native-material-kit).
Instead of now doing `animatedNode._component` (that might later break again), getNode() is a more 'public' solution for these third party.

as you expose a way to create an animated component (`createAnimatedComponent`) you sometimes still want a way to get the reference.
That way, third party components can continue providing some extra native methods to the animated version.
Closes #9944

Differential Revision: D3885973

Pulled By: foghina

fbshipit-source-id: 43ffdbfe7f9c52f5a1689e6a9a4052d4973f5c5f
  • Loading branch information
gre authored and Facebook Github Bot 8 committed Sep 19, 2016
1 parent bdff10b commit 19d0429
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/Animated/src/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,12 @@ function createAnimatedComponent(Component: any): any {
_setComponentRef(c) {
this._component = c;
}

// A third party library can use getNode()
// to get the node reference of the decorated component
getNode () {
return this._component;
}
}
AnimatedComponent.propTypes = {
style: function(props, propName, componentName) {
Expand Down

0 comments on commit 19d0429

Please sign in to comment.