react-native-onyx 3.0.98 → 3.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/useOnyx.js +6 -0
  2. package/package.json +1 -1
package/dist/useOnyx.js CHANGED
@@ -99,6 +99,12 @@ function useOnyx(key, options) {
99
99
  if (!shouldGetCachedValueRef.current) {
100
100
  const cachedResult = OnyxSnapshotCache_1.default.getCachedResult(key, cacheKey);
101
101
  if (cachedResult !== undefined) {
102
+ // The slot is shared by all subscribers of the same (key, selector) pair, so it can hold a content-equal
103
+ // result computed by another subscriber. Keep our own result then, otherwise we would needlessly change
104
+ // this hook's result identity and re-render its consumer.
105
+ if (cachedResult !== resultRef.current && (0, memoizedShallowEqual_1.default)(cachedResult[0], resultRef.current[0]) && cachedResult[1].status === resultRef.current[1].status) {
106
+ return resultRef.current;
107
+ }
102
108
  resultRef.current = cachedResult;
103
109
  return cachedResult;
104
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "3.0.98",
3
+ "version": "3.0.99",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",