source: node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.native.development.js@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/**
2 * @license React
3 * use-sync-external-store-shim.native.development.js
4 *
5 * Copyright (c) Meta Platforms, Inc. and affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */
10
11"use strict";
12"production" !== process.env.NODE_ENV &&
13 (function () {
14 function is(x, y) {
15 return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
16 }
17 function useSyncExternalStore$1(subscribe, getSnapshot) {
18 didWarnOld18Alpha ||
19 void 0 === React.startTransition ||
20 ((didWarnOld18Alpha = !0),
21 console.error(
22 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
23 ));
24 var value = getSnapshot();
25 if (!didWarnUncachedGetSnapshot) {
26 var cachedValue = getSnapshot();
27 objectIs(value, cachedValue) ||
28 (console.error(
29 "The result of getSnapshot should be cached to avoid an infinite loop"
30 ),
31 (didWarnUncachedGetSnapshot = !0));
32 }
33 cachedValue = useState({
34 inst: { value: value, getSnapshot: getSnapshot }
35 });
36 var inst = cachedValue[0].inst,
37 forceUpdate = cachedValue[1];
38 useLayoutEffect(
39 function () {
40 inst.value = value;
41 inst.getSnapshot = getSnapshot;
42 checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
43 },
44 [subscribe, value, getSnapshot]
45 );
46 useEffect(
47 function () {
48 checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
49 return subscribe(function () {
50 checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
51 });
52 },
53 [subscribe]
54 );
55 useDebugValue(value);
56 return value;
57 }
58 function checkIfSnapshotChanged(inst) {
59 var latestGetSnapshot = inst.getSnapshot;
60 inst = inst.value;
61 try {
62 var nextValue = latestGetSnapshot();
63 return !objectIs(inst, nextValue);
64 } catch (error) {
65 return !0;
66 }
67 }
68 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
69 "function" ===
70 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
71 __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
72 var React = require("react"),
73 objectIs = "function" === typeof Object.is ? Object.is : is,
74 useState = React.useState,
75 useEffect = React.useEffect,
76 useLayoutEffect = React.useLayoutEffect,
77 useDebugValue = React.useDebugValue,
78 didWarnOld18Alpha = !1,
79 didWarnUncachedGetSnapshot = !1;
80 exports.useSyncExternalStore =
81 void 0 !== React.useSyncExternalStore
82 ? React.useSyncExternalStore
83 : useSyncExternalStore$1;
84 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
85 "function" ===
86 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
87 __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
88 })();
Note: See TracBrowser for help on using the repository browser.