Skip to content

Commit

Permalink
Fix invariant in scrollResponderZoomTo
Browse files Browse the repository at this point in the history
Summary:
This fixes a cryptic bug to appear when you try to use scrollResponderZoomTo in Android.
before this PR it would break with a `Error: TaskQueue: Error with task : invariant requires an error message argument` because the invariant() was not properly used..

Also, instead of detecting the platform, I think it's better practice to duck type.
Closes #11186

Differential Revision: D4246674

fbshipit-source-id: 47002a85d8252e5abbd1cd9ecef3d7676fa8615a
  • Loading branch information
gre authored and Facebook Github Bot committed Nov 29, 2016
1 parent aac8daf commit 20e99f5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,13 @@ var ScrollResponderMixin = {
rect: { x: number, y: number, width: number, height: number, animated?: boolean },
animated?: boolean // deprecated, put this inside the rect argument instead
) {
if (Platform.OS === 'android') {
invariant('zoomToRect is not implemented');
} else {
if ('animated' in rect) {
var { animated, ...rect } = rect;
} else if (typeof animated !== 'undefined') {
console.warn('`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead');
}
ScrollViewManager.zoomToRect(this.scrollResponderGetScrollableNode(), rect, animated !== false);
invariant(ScrollViewManager && ScrollViewManager.zoomToRect, 'zoomToRect is not implemented');
if ('animated' in rect) {
var { animated, ...rect } = rect;
} else if (typeof animated !== 'undefined') {
console.warn('`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead');
}
ScrollViewManager.zoomToRect(this.scrollResponderGetScrollableNode(), rect, animated !== false);
},

/**
Expand Down

0 comments on commit 20e99f5

Please sign in to comment.