diff --git a/packages/shared/objectIs.js b/packages/shared/objectIs.js index 608adfc3bcf..cf7ee2d1d88 100644 --- a/packages/shared/objectIs.js +++ b/packages/shared/objectIs.js @@ -11,12 +11,18 @@ * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is */ -function is(x: any, y: any) { +function is(x, y) { + if (typeof x !== typeof y) { + return false; + } + return ( - (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + (x === y && (x !== 0 || 1 / x === 1 / y)) || + (x !== x && y !== y) ); } + const objectIs: (x: any, y: any) => boolean = // $FlowFixMe[method-unbinding] typeof Object.is === 'function' ? Object.is : is;