react-native-onyx 1.0.25 → 1.0.26

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/lib/Onyx.js CHANGED
@@ -1046,6 +1046,11 @@ function clear() {
1046
1046
  * @returns {Promise}
1047
1047
  */
1048
1048
  function mergeCollection(collectionKey, collection) {
1049
+ if (!_.isObject(collection) || _.isArray(collection) || _.isEmpty(collection)) {
1050
+ Logger.logInfo('mergeCollection() called with invalid or empty value. Skipping this update.');
1051
+ return Promise.resolve();
1052
+ }
1053
+
1049
1054
  // Confirm all the collection keys belong to the same parent
1050
1055
  _.each(collection, (_data, dataKey) => {
1051
1056
  if (isKeyMatch(collectionKey, dataKey)) {
package/lib/OnyxCache.js CHANGED
@@ -111,6 +111,10 @@ class OnyxCache {
111
111
  * @param {Record<string, *>} data - a map of (cache) key - values
112
112
  */
113
113
  merge(data) {
114
+ if (!_.isObject(data) || _.isArray(data)) {
115
+ throw new Error('data passed to cache.merge() must be an Object of onyx key/value pairs');
116
+ }
117
+
114
118
  // lodash adds a small overhead so we don't use it here
115
119
  // eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
116
120
  this.storageMap = Object.assign({}, fastMerge(this.storageMap, data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",