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 https://github.com/facebook/react-native/pull/11186 Differential Revision: D4246674 fbshipit-source-id: 47002a85d8252e5abbd1cd9ecef3d7676fa8615a
This commit is contained in:
parent
aac8daf378
commit
20e99f5b93
|
@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue