react-native-onyx 3.0.43 → 3.0.45

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.
@@ -39,12 +39,11 @@ declare class OnyxSnapshotCache {
39
39
  *
40
40
  * - `selector`: Different selectors produce different results, so each selector needs its own cache entry
41
41
  * - `initWithStoredValues`: This flag changes the initial loading behavior and affects the returned fetch status
42
- * - `allowStaleData`: Controls whether stale data can be returned during pending merges, affecting result timing
43
42
  *
44
43
  * Other options like `canEvict`, `reuseConnection`, and `allowDynamicKey` don't affect the data transformation
45
44
  * or timing behavior of getSnapshot, so they're excluded from the cache key for better cache hit rates.
46
45
  */
47
- registerConsumer<TKey extends OnyxKey, TReturnValue>(options: Pick<UseOnyxOptions<TKey, TReturnValue>, 'selector' | 'initWithStoredValues' | 'allowStaleData'>): string;
46
+ registerConsumer<TKey extends OnyxKey, TReturnValue>(options: Pick<UseOnyxOptions<TKey, TReturnValue>, 'selector' | 'initWithStoredValues'>): string;
48
47
  /**
49
48
  * Deregister a consumer for a cache key.
50
49
  * Decrements reference counter and removes cache entry if no consumers remain.
@@ -36,18 +36,16 @@ class OnyxSnapshotCache {
36
36
  *
37
37
  * - `selector`: Different selectors produce different results, so each selector needs its own cache entry
38
38
  * - `initWithStoredValues`: This flag changes the initial loading behavior and affects the returned fetch status
39
- * - `allowStaleData`: Controls whether stale data can be returned during pending merges, affecting result timing
40
39
  *
41
40
  * Other options like `canEvict`, `reuseConnection`, and `allowDynamicKey` don't affect the data transformation
42
41
  * or timing behavior of getSnapshot, so they're excluded from the cache key for better cache hit rates.
43
42
  */
44
43
  registerConsumer(options) {
45
- var _a, _b;
44
+ var _a;
46
45
  const selectorID = (options === null || options === void 0 ? void 0 : options.selector) ? this.getSelectorID(options.selector) : 'no_selector';
47
46
  // Create options hash without expensive JSON.stringify
48
47
  const initWithStoredValues = (_a = options === null || options === void 0 ? void 0 : options.initWithStoredValues) !== null && _a !== void 0 ? _a : true;
49
- const allowStaleData = (_b = options === null || options === void 0 ? void 0 : options.allowStaleData) !== null && _b !== void 0 ? _b : false;
50
- const cacheKey = `${selectorID}_${initWithStoredValues}_${allowStaleData}`;
48
+ const cacheKey = `${selectorID}_${initWithStoredValues}`;
51
49
  // Increment reference count for this cache key
52
50
  const currentCount = this.cacheKeyRefCounts.get(cacheKey) || 0;
53
51
  this.cacheKeyRefCounts.set(cacheKey, currentCount + 1);
package/dist/useOnyx.d.ts CHANGED
@@ -11,10 +11,6 @@ type UseOnyxOptions<TKey extends OnyxKey, TReturnValue> = {
11
11
  * @deprecated This param is going to be removed soon. Use RAM-only keys instead.
12
12
  */
13
13
  initWithStoredValues?: boolean;
14
- /**
15
- * If set to `true`, data will be retrieved from cache during the first render even if there is a pending merge for the key.
16
- */
17
- allowStaleData?: boolean;
18
14
  /**
19
15
  * If set to `false`, the connection won't be reused between other subscribers that are listening to the same Onyx key
20
16
  * with the same connect configurations.
package/dist/useOnyx.js CHANGED
@@ -109,8 +109,7 @@ function useOnyx(key, options, dependencies = []) {
109
109
  const cacheKey = (0, react_1.useMemo)(() => OnyxSnapshotCache_1.default.registerConsumer({
110
110
  selector: options === null || options === void 0 ? void 0 : options.selector,
111
111
  initWithStoredValues: options === null || options === void 0 ? void 0 : options.initWithStoredValues,
112
- allowStaleData: options === null || options === void 0 ? void 0 : options.allowStaleData,
113
- }), [options === null || options === void 0 ? void 0 : options.selector, options === null || options === void 0 ? void 0 : options.initWithStoredValues, options === null || options === void 0 ? void 0 : options.allowStaleData]);
112
+ }), [options === null || options === void 0 ? void 0 : options.selector, options === null || options === void 0 ? void 0 : options.initWithStoredValues]);
114
113
  (0, react_1.useEffect)(() => () => OnyxSnapshotCache_1.default.deregisterConsumer(key, cacheKey), [key, cacheKey]);
115
114
  (0, react_1.useEffect)(() => {
116
115
  // These conditions will ensure we can only handle dynamic collection member keys from the same collection.
@@ -206,8 +205,7 @@ function useOnyx(key, options, dependencies = []) {
206
205
  let newFetchStatus;
207
206
  // If we have pending merge operations for the key during the first connection, we set the new value to `undefined`
208
207
  // and fetch status to `loading` to simulate that it is still being loaded until we have the most updated data.
209
- // If `allowStaleData` is `true` this logic will be ignored and cached value will be used, even if it's stale data.
210
- if (isFirstConnectionRef.current && OnyxUtils_1.default.hasPendingMergeForKey(key) && !(options === null || options === void 0 ? void 0 : options.allowStaleData)) {
208
+ if (isFirstConnectionRef.current && OnyxUtils_1.default.hasPendingMergeForKey(key)) {
211
209
  newValueRef.current = undefined;
212
210
  newFetchStatus = 'loading';
213
211
  }
@@ -248,7 +246,7 @@ function useOnyx(key, options, dependencies = []) {
248
246
  OnyxSnapshotCache_1.default.setCachedResult(key, cacheKey, resultRef.current);
249
247
  }
250
248
  return resultRef.current;
251
- }, [options === null || options === void 0 ? void 0 : options.initWithStoredValues, options === null || options === void 0 ? void 0 : options.allowStaleData, key, memoizedSelector, cacheKey, previousKey]);
249
+ }, [options === null || options === void 0 ? void 0 : options.initWithStoredValues, key, memoizedSelector, cacheKey, previousKey]);
252
250
  const subscribe = (0, react_1.useCallback)((onStoreChange) => {
253
251
  isConnectingRef.current = true;
254
252
  onStoreChangeFnRef.current = onStoreChange;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "3.0.43",
3
+ "version": "3.0.45",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",