use-sync-external-store
Advanced tools
Comparing version 0.0.0-experimental-1314299c7-20210901 to 0.0.0-experimental-33226fada-20210913
@@ -78,3 +78,4 @@ /** @license React vundefined | ||
var useSyncExternalStore = builtInAPI !== undefined ? builtInAPI : useSyncExternalStore_shim; | ||
var didWarnOld18Alpha = false; // Disclaimer: This shim breaks many of the rules of React, and only works | ||
var didWarnOld18Alpha = false; | ||
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works | ||
// because of a very particular set of implementation details and assumptions | ||
@@ -105,3 +106,13 @@ // -- change any one of them and it will break. The most important assumption | ||
var value = getSnapshot(); // Because updates are synchronous, we don't queue them. Instead we force a | ||
var value = getSnapshot(); | ||
{ | ||
if (!didWarnUncachedGetSnapshot) { | ||
if (value !== getSnapshot()) { | ||
error('The result of getSnapshot should be cached to avoid an infinite loop'); | ||
didWarnUncachedGetSnapshot = true; | ||
} | ||
} | ||
} // Because updates are synchronous, we don't queue them. Instead we force a | ||
// re-render whenever the subscribed state changes by updating an some | ||
@@ -121,2 +132,3 @@ // arbitrary useState hook. Then, during render, we call getSnapshot to read | ||
var _useState = useState({ | ||
@@ -123,0 +135,0 @@ inst: { |
{ | ||
"name": "use-sync-external-store", | ||
"description": "Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.", | ||
"version": "0.0.0-experimental-1314299c7-20210901", | ||
"version": "0.0.0-experimental-33226fada-20210913", | ||
"repository": { | ||
@@ -20,4 +20,4 @@ "type": "git", | ||
"peerDependencies": { | ||
"react": "0.0.0-experimental-1314299c7-20210901" | ||
"react": "0.0.0-experimental-33226fada-20210913" | ||
} | ||
} |
14185
274