shallowEqual() — react Function Reference
Architecture documentation for the shallowEqual() function in shallowEqual.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 32442e80_d840_f60a_a31a_ea0e39ac487a["shallowEqual()"] 453d8884_196c_9b47_f492_31e5c07005e7["shallowEqual.js"] 32442e80_d840_f60a_a31a_ea0e39ac487a -->|defined in| 453d8884_196c_9b47_f492_31e5c07005e7 dab343e7_d491_ab84_5374_66898c315624["is()"] 32442e80_d840_f60a_a31a_ea0e39ac487a -->|calls| dab343e7_d491_ab84_5374_66898c315624 style 32442e80_d840_f60a_a31a_ea0e39ac487a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shared/shallowEqual.js lines 18–52
function shallowEqual(objA: mixed, objB: mixed): boolean {
if (is(objA, objB)) {
return true;
}
if (
typeof objA !== 'object' ||
objA === null ||
typeof objB !== 'object' ||
objB === null
) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
for (let i = 0; i < keysA.length; i++) {
const currentKey = keysA[i];
if (
!hasOwnProperty.call(objB, currentKey) ||
// $FlowFixMe[incompatible-use] lost refinement of `objB`
!is(objA[currentKey], objB[currentKey])
) {
return false;
}
}
return true;
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does shallowEqual() do?
shallowEqual() is a function in the react codebase, defined in packages/shared/shallowEqual.js.
Where is shallowEqual() defined?
shallowEqual() is defined in packages/shared/shallowEqual.js at line 18.
What does shallowEqual() call?
shallowEqual() calls 1 function(s): is.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free