react-native-onyx 1.0.67 → 1.0.69

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.
@@ -2268,6 +2268,9 @@ const provider = {
2268
2268
  */
2269
2269
  clear: () => (0,idb_keyval__WEBPACK_IMPORTED_MODULE_0__.clear)(getCustomStore()),
2270
2270
 
2271
+ // This is a noop for now in order to keep clients from crashing see https://github.com/Expensify/Expensify/issues/312438
2272
+ setMemoryOnlyKeys: () => {},
2273
+
2271
2274
  /**
2272
2275
  * Returns all keys available in storage
2273
2276
  * @returns {Promise<String[]>}
@@ -2473,14 +2476,15 @@ function getDisplayName(component) {
2473
2476
  return;
2474
2477
  }
2475
2478
 
2476
- const stateUpdate = { ...this.tempState, loading: false };
2479
+ // Leave untouched previous state to avoid data loss during pre-load updates.
2480
+ // This handles case when setState was called before the setWithOnyxState.
2481
+ // For example, when an Onyx property was updated by keyChanged before the call of the setWithOnyxState.
2482
+ this.setState((prevState) => {
2483
+ const remainingTempState = underscore__WEBPACK_IMPORTED_MODULE_2___default().omit(this.tempState, underscore__WEBPACK_IMPORTED_MODULE_2___default().keys(prevState));
2477
2484
 
2478
- // The state is set here manually, instead of using setState because setState is an async operation, meaning it might execute on the next tick,
2479
- // or at a later point in the microtask queue. That can lead to a race condition where
2480
- // setWithOnyxState is called before the state is actually set. This results in unreliable behavior when checking the loading state and has been mainly observed on fabric.
2481
- this.state = stateUpdate;
2485
+ return { ...remainingTempState, loading: false };
2486
+ });
2482
2487
 
2483
- this.setState(stateUpdate); // Trigger a render
2484
2488
  delete this.tempState;
2485
2489
  }
2486
2490