Skip to content

Commit 05940da

Browse files
committed
Remove external object-is dependency
1 parent 4e512cb commit 05940da

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@
3535
"@babel/preset-react"
3636
]
3737
},
38-
"jest": {
39-
"globals": {
40-
"__DEV__": true
41-
}
42-
},
4338
"lint-staged": {
4439
"**/*.js": [
4540
"flow focus-check",
@@ -58,9 +53,7 @@
5853
"react": "^16.8.0",
5954
"react-is": "^16.8.0"
6055
},
61-
"dependencies": {
62-
"object-is": "^1.1.2"
63-
},
56+
"dependencies": {},
6457
"devDependencies": {
6558
"@ampproject/rollup-plugin-closure-compiler": "^0.25.2",
6659
"@babel/core": "^7.9.0",

src/internals/dispatcher.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
22
// Source: https://github.com/facebook/react/blob/c21c41e/packages/react-dom/src/server/ReactPartialRendererHooks.js
33

4-
import is from 'object-is'
54
import { readContextValue } from './context'
5+
import is from './objectIs'
66

77
import type {
88
AbstractContext,
@@ -159,7 +159,7 @@ function useState<S>(
159159
function useReducer<S, I, A>(
160160
reducer: (S, A) => S,
161161
initialArg: I,
162-
init?: I => S
162+
init?: (I) => S
163163
): [S, Dispatch<A>] {
164164
const id = getCurrentIdentity()
165165
workInProgressHook = createWorkInProgressHook()
@@ -287,7 +287,7 @@ function useCallback<T>(callback: T, deps: Array<mixed> | void | null): T {
287287
function noop(): void {}
288288

289289
function useTransition(): [(callback: () => void) => void, boolean] {
290-
const startTransition = callback => {
290+
const startTransition = (callback) => {
291291
callback()
292292
}
293293
return [startTransition, false]

src/internals/objectIs.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
/**
11+
* inlined Object.is polyfill to avoid requiring consumers ship their own
12+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
13+
*/
14+
function is(x: any, y: any) {
15+
return (
16+
(x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
17+
)
18+
}
19+
20+
const objectIs: (x: any, y: any) => boolean =
21+
typeof Object.is === 'function' ? Object.is : is
22+
23+
export default objectIs

types/globals.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

types/object-is.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3901,14 +3901,6 @@ object-inspect@^1.7.0:
39013901
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67"
39023902
integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==
39033903

3904-
object-is@^1.1.2:
3905-
version "1.1.2"
3906-
resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6"
3907-
integrity sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==
3908-
dependencies:
3909-
define-properties "^1.1.3"
3910-
es-abstract "^1.17.5"
3911-
39123904
object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1:
39133905
version "1.1.1"
39143906
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"

0 commit comments

Comments
 (0)