MCPcopy
hub / github.com/reduxjs/react-redux / shallowEqual

Function shallowEqual

src/utils/shallowEqual.ts:9–36  ·  view source on GitHub ↗
(objA: any, objB: any)

Source from the content-addressed store, hash-verified

7}
8
9export default function shallowEqual(objA: any, objB: any) {
10 if (is(objA, objB)) return true
11
12 if (
13 typeof objA !== 'object' ||
14 objA === null ||
15 typeof objB !== 'object' ||
16 objB === null
17 ) {
18 return false
19 }
20
21 const keysA = Object.keys(objA)
22 const keysB = Object.keys(objB)
23
24 if (keysA.length !== keysB.length) return false
25
26 for (let i = 0; i < keysA.length; i++) {
27 if (
28 !Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||
29 !is(objA[keysA[i]], objB[keysA[i]])
30 ) {
31 return false
32 }
33 }
34
35 return true
36}

Callers 1

Calls 1

isFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…