react-native-onyx 3.0.19 → 3.0.20
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.
- package/dist/useOnyx.js +6 -4
- package/package.json +1 -1
package/dist/useOnyx.js
CHANGED
|
@@ -234,22 +234,24 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
234
234
|
if (shouldUpdateResult) {
|
|
235
235
|
previousValueRef.current = newValueRef.current;
|
|
236
236
|
// If the new value is `null` we default it to `undefined` to ensure the consumer gets a consistent result from the hook.
|
|
237
|
-
|
|
237
|
+
newFetchStatus = newFetchStatus !== null && newFetchStatus !== void 0 ? newFetchStatus : 'loaded';
|
|
238
238
|
resultRef.current = [
|
|
239
239
|
(_d = previousValueRef.current) !== null && _d !== void 0 ? _d : undefined,
|
|
240
240
|
{
|
|
241
|
-
status:
|
|
241
|
+
status: newFetchStatus,
|
|
242
242
|
sourceValue: sourceValueRef.current,
|
|
243
243
|
},
|
|
244
244
|
];
|
|
245
245
|
// If `canBeMissing` is set to `false` and the Onyx value of that key is not defined,
|
|
246
246
|
// we log an alert so it can be acknowledged by the consumer. Additionally, we won't log alerts
|
|
247
247
|
// if there's a `Onyx.clear()` task in progress.
|
|
248
|
-
if ((options === null || options === void 0 ? void 0 : options.canBeMissing) === false &&
|
|
248
|
+
if ((options === null || options === void 0 ? void 0 : options.canBeMissing) === false && newFetchStatus === 'loaded' && !isOnyxValueDefined && !OnyxCache_1.default.hasPendingTask(OnyxCache_1.TASK.CLEAR)) {
|
|
249
249
|
Logger.logAlert(`useOnyx returned no data for key with canBeMissing set to false for key ${key}`, { showAlert: true });
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
if (newFetchStatus !== 'loading') {
|
|
253
|
+
OnyxSnapshotCache_1.default.setCachedResult(key, cacheKey, resultRef.current);
|
|
254
|
+
}
|
|
253
255
|
return resultRef.current;
|
|
254
256
|
}, [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.canBeMissing, key, memoizedSelector, cacheKey]);
|
|
255
257
|
const subscribe = (0, react_1.useCallback)((onStoreChange) => {
|