react-native-onyx 2.0.69 → 2.0.70

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 -2
  2. package/package.json +1 -1
package/dist/useOnyx.js CHANGED
@@ -26,7 +26,7 @@ function useOnyx(key, options) {
26
26
  const newValueRef = (0, react_1.useRef)(null);
27
27
  // Stores the previously result returned by the hook, containing the data from cache and the fetch status.
28
28
  // We initialize it to `undefined` and `loading` fetch status to simulate the initial result when the hook is loading from the cache.
29
- // However, if `initWithStoredValues` is `true` we set the fetch status to `loaded` since we want to signal that data is ready.
29
+ // However, if `initWithStoredValues` is `false` we set the fetch status to `loaded` since we want to signal that data is ready.
30
30
  const resultRef = (0, react_1.useRef)([
31
31
  undefined,
32
32
  {
@@ -74,6 +74,10 @@ function useOnyx(key, options) {
74
74
  }, [key, options === null || options === void 0 ? void 0 : options.canEvict]);
75
75
  const getSnapshot = (0, react_1.useCallback)(() => {
76
76
  var _a, _b, _c;
77
+ // We return the initial result right away during the first connection if `initWithStoredValues` is set to `false`.
78
+ if (isFirstConnectionRef.current && (options === null || options === void 0 ? void 0 : options.initWithStoredValues) === false) {
79
+ return resultRef.current;
80
+ }
77
81
  // We get the value from cache while the first connection to Onyx is being made,
78
82
  // so we can return any cached value right away. After the connection is made, we only
79
83
  // update `newValueRef` when `Onyx.connect()` callback is fired.
@@ -123,7 +127,7 @@ function useOnyx(key, options) {
123
127
  resultRef.current = [previousValueRef.current, { status: newFetchStatus !== null && newFetchStatus !== void 0 ? newFetchStatus : 'loaded' }];
124
128
  }
125
129
  return resultRef.current;
126
- }, [key, selectorRef, options === null || options === void 0 ? void 0 : options.allowStaleData, options === null || options === void 0 ? void 0 : options.initialValue]);
130
+ }, [key, selectorRef, options === null || options === void 0 ? void 0 : options.initWithStoredValues, options === null || options === void 0 ? void 0 : options.allowStaleData, options === null || options === void 0 ? void 0 : options.initialValue]);
127
131
  const subscribe = (0, react_1.useCallback)((onStoreChange) => {
128
132
  connectionRef.current = OnyxConnectionManager_1.default.connect({
129
133
  key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.69",
3
+ "version": "2.0.70",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",