react-native-onyx 1.0.107 → 1.0.109

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.
@@ -318,8 +318,14 @@ function tryGetCachedValue(key) {let mapping = arguments.length > 1 && arguments
318
318
  let val = _OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].getValue(key);
319
319
 
320
320
  if (isCollectionKey(key)) {
321
- const allKeys = _OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].getAllKeys();
322
- const matchingKeys = underscore__WEBPACK_IMPORTED_MODULE_1___default().filter(allKeys, (k) => k.startsWith(key));
321
+ const allCacheKeys = _OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].getAllKeys();
322
+
323
+ // It is possible we haven't loaded all keys yet so we do not know if the
324
+ // collection actually exists.
325
+ if (allCacheKeys.length === 0) {
326
+ return;
327
+ }
328
+ const matchingKeys = underscore__WEBPACK_IMPORTED_MODULE_1___default().filter(allCacheKeys, (k) => k.startsWith(key));
323
329
  const values = underscore__WEBPACK_IMPORTED_MODULE_1___default().reduce(matchingKeys, (finalObject, matchedKey) => {
324
330
  const cachedValue = _OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].getValue(matchedKey);
325
331
  if (cachedValue) {
@@ -329,9 +335,7 @@ function tryGetCachedValue(key) {let mapping = arguments.length > 1 && arguments
329
335
  }
330
336
  return finalObject;
331
337
  }, {});
332
- if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isEmpty(values)) {
333
- return;
334
- }
338
+
335
339
  val = values;
336
340
  }
337
341
 
@@ -909,6 +913,10 @@ function connect(mapping) {
909
913
  // since there are none matched. In withOnyx() we wait for all connected keys to return a value before rendering the child
910
914
  // component. This null value will be filtered out so that the connected component can utilize defaultProps.
911
915
  if (matchingKeys.length === 0) {
916
+ if (mapping.key && !isCollectionKey(mapping.key)) {
917
+ _OnyxCache__WEBPACK_IMPORTED_MODULE_4__["default"].set(mapping.key, null);
918
+ }
919
+
912
920
  // Here we cannot use batching because the null value is expected to be set immediately for default props
913
921
  // or they will be undefined.
914
922
  sendDataToConnection(mapping, null, undefined, false);