From 7b2ee7119a56054edf1425cda31649c4d0490c23 Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Mon, 14 Nov 2016 20:49:57 -0800 Subject: [PATCH] Unbreak custom animated components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Commit https://github.com/facebook/react-native/commit/c9960817eea008b2703657066212002557e0d939 broke `Animated.createAnimatedComponent()` for most components outside of the standard ones. This is because it will throw an exception for any component without a `viewConfig` defined, which basically no composition style component has AFAIK. Related issues: https://github.com/facebook/react-native/issues/10825, https://github.com/oblador/react-native-vector-icons/issues/337, https://github.com/oblador/react-native-animatable/issues/70 This PR removes the check which is more treating the symptoms really – but shouldn't `setNativeProps` duck typing be enough? Closes https://github.com/facebook/react-native/pull/10827 Differential Revision: D4178183 Pulled By: ericvicenti fbshipit-source-id: b85cc78ed6d84dada4d476caa243332eaadb003f --- Libraries/Animated/src/AnimatedImplementation.js | 6 ------ .../Renderer/src/renderers/native/NativeMethodsMixin.js | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index a1d43d2eeed..cba4f4dff8b 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -1735,12 +1735,6 @@ function createAnimatedComponent(Component: any): any { var callback = () => { if (this._component.setNativeProps) { if (!this._propsAnimated.__isNative) { - if (this._component.viewConfig == null) { - var ctor = this._component.constructor; - var componentName = ctor.displayName || ctor.name || ''; - throw new Error(componentName + ' "viewConfig" is not defined.'); - } - this._component.setNativeProps( this._propsAnimated.__getAnimatedValue() ); diff --git a/Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js b/Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js index eb2818f7042..c97aa273992 100644 --- a/Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js +++ b/Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js @@ -139,6 +139,12 @@ var NativeMethodsMixin = { * Manipulation](docs/direct-manipulation.html)). */ setNativeProps: function(nativeProps: Object) { + if (!this.viewConfig) { + var ctor = this.constructor; + var componentName = ctor.displayName || ctor.name || ''; + invariant(false, componentName + ' "viewConfig" is not defined.'); + } + if (__DEV__) { warnForStyleProps(nativeProps, this.viewConfig.validAttributes); }