react-native-onyx 1.0.95 → 1.0.96

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.
@@ -2671,7 +2671,13 @@ function getDisplayName(component) {
2671
2671
  const prevValue = this.state[statePropertyName];
2672
2672
 
2673
2673
  // If the component is not loading (read "mounting"), then we can just update the state
2674
- if (!this.state.loading) {
2674
+ // There is a small race condition.
2675
+ // When calling setWithOnyxState we delete the tempState object that is used to hold temporary state updates while the HOC is gathering data.
2676
+ // However the loading flag is only set on the setState callback down below. setState however is an async operation that is also batched,
2677
+ // therefore there is a small window of time where the loading flag is not false but the tempState is already gone
2678
+ // (while the update is queued and waiting to be applied).
2679
+ // This simply bypasses the loading check if the tempState is gone and the update can be safely queued with a normal setStateProxy.
2680
+ if (!this.state.loading || !this.tempState) {
2675
2681
  // Performance optimization, do not trigger update with same values
2676
2682
  if (prevValue === val || _utils__WEBPACK_IMPORTED_MODULE_5__["default"].areObjectsEmpty(prevValue, val)) {
2677
2683
  return;