MCPcopy Create free account
hub / github.com/Lobos/react-ui / shallowEqual

Function shallowEqual

src/utils/objects.js:102–126  ·  view source on GitHub ↗
(objA, objB)

Source from the content-addressed store, hash-verified

100}
101
102export function shallowEqual(objA, objB) {
103 if (objA === objB) {
104 return true;
105 }
106
107 if (typeof objA !== 'object' || objA === null ||
108 typeof objB !== 'object' || objB === null) {
109 return false;
110 }
111
112 const keysA = Object.keys(objA);
113
114 if (keysA.length !== Object.keys(objB).length) {
115 return false;
116 }
117
118 for (let i = 0, key; i < keysA.length; i++) {
119 key = keysA[i];
120 if (!objB.hasOwnProperty(key) || objA[key] !== objB[key]) {
121 return false;
122 }
123 }
124
125 return true;
126}

Callers 5

shouldComponentUpdateMethod · 0.90
shouldComponentUpdateMethod · 0.90
shouldComponentUpdateMethod · 0.90
shouldComponentUpdateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…