Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Libraries/Animated/src/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1747,12 +1747,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 || '<Unknown Component>';
throw new Error(componentName + ' "viewConfig" is not defined.');
}

this._component.setNativeProps(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should ensure viewConfig exists before call setNativeProps

if (this._component.viewConfig != null) {
  this._component.setNativeProps(...);
}

See https://github.com/facebook/react-native/blob/master/Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js#L141-L156

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can change throw new Erorr to console.warn??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leeight The problem is that custom components can proxy the setNativeProps call to the wrapped component which will throw/warn even though it's valid use. Isn't it better to do this check in the setNativeProps function instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oblador

Isn't it better to do this check in the setNativeProps function instead?

LGTM

this._propsAnimated.__getAnimatedValue()
);
Expand Down
6 changes: 6 additions & 0 deletions Libraries/Renderer/src/renderers/native/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '<Unknown Component>';
invariant(false, componentName + ' "viewConfig" is not defined.');
}

if (__DEV__) {
warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
}
Expand Down