Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TanStack/store/llms.txt
Use this file to discover all available pages before exploring further.
Reference
shallow
useStore to prevent unnecessary re-renders when selecting object slices.
The first value to compare.
The second value to compare.
Returns
true if the values are shallowly equal, false otherwise.Comparison Behavior
Theshallow function handles various data types:
- Reference equality: Returns
trueifObject.is(objA, objB) - Primitives/null: Returns
falseif either value is not an object - Map: Compares size and all entries using
Object.is - Set: Compares size and all values for presence
- Date: Compares timestamps using
getTime() - Objects: Compares own properties (including symbols) using
Object.is
Usage
With useStore
Selecting Object Slices
With Arrays
Notes
- Only compares own properties at the first level (shallow)
- For nested objects, only the reference is compared
- Handles special object types: Map, Set, Date
- Includes symbol properties in comparison
- More efficient than deep equality for most React use cases
- Use reference equality (default) if selecting primitive values or when you want strict reference checks