Skip to content

Commit 20e99f5

Browse files
greFacebook Github Bot
authored and
Facebook Github Bot
committed
Fix invariant in scrollResponderZoomTo
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
1 parent aac8daf commit 20e99f5

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Libraries/Components/ScrollResponder.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,13 @@ var ScrollResponderMixin = {
410410
rect: { x: number, y: number, width: number, height: number, animated?: boolean },
411411
animated?: boolean // deprecated, put this inside the rect argument instead
412412
) {
413-
if (Platform.OS === 'android') {
414-
invariant('zoomToRect is not implemented');
415-
} else {
416-
if ('animated' in rect) {
417-
var { animated, ...rect } = rect;
418-
} else if (typeof animated !== 'undefined') {
419-
console.warn('`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead');
420-
}
421-
ScrollViewManager.zoomToRect(this.scrollResponderGetScrollableNode(), rect, animated !== false);
413+
invariant(ScrollViewManager && ScrollViewManager.zoomToRect, 'zoomToRect is not implemented');
414+
if ('animated' in rect) {
415+
var { animated, ...rect } = rect;
416+
} else if (typeof animated !== 'undefined') {
417+
console.warn('`scrollResponderZoomTo` `animated` argument is deprecated. Use `options.animated` instead');
422418
}
419+
ScrollViewManager.zoomToRect(this.scrollResponderGetScrollableNode(), rect, animated !== false);
423420
},
424421

425422
/**

0 commit comments

Comments
 (0)