react-native-onyx 3.0.29 → 3.0.30
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 +3 -3
- package/package.json +1 -1
package/dist/useOnyx.js
CHANGED
|
@@ -186,10 +186,10 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
186
186
|
OnyxSnapshotCache_1.default.setCachedResult(key, cacheKey, result);
|
|
187
187
|
return result;
|
|
188
188
|
}
|
|
189
|
-
// We get the value from cache while the first connection to Onyx is being made,
|
|
190
|
-
// so we can return any cached value right away. After the connection is made, we only
|
|
189
|
+
// We get the value from cache while the first connection to Onyx is being made or if the key has changed,
|
|
190
|
+
// so we can return any cached value right away. For the case where the key has changed, If we don't return the cached value right away, then the UI will show the incorrect (previous) value for a brief period which looks like a UI glitch to the user. After the connection is made, we only
|
|
191
191
|
// update `newValueRef` when `Onyx.connect()` callback is fired.
|
|
192
|
-
if (isFirstConnectionRef.current || shouldGetCachedValueRef.current) {
|
|
192
|
+
if (isFirstConnectionRef.current || shouldGetCachedValueRef.current || key !== previousKey) {
|
|
193
193
|
// Gets the value from cache and maps it with selector. It changes `null` to `undefined` for `useOnyx` compatibility.
|
|
194
194
|
const value = OnyxUtils_1.default.tryGetCachedValue(key);
|
|
195
195
|
const selectedValue = memoizedSelector ? memoizedSelector(value) : value;
|