Mercurial
annotate third_party/bun/node_modules/react/cjs/react.development.js @ 52:636eab07809d
Fixed dowa memory problems. Add few more utility functions.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 19 Dec 2025 13:30:30 -0800 |
| parents | de54585a40f1 |
| children |
| rev | line source |
|---|---|
|
12
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2 * @license React |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3 * react.development.js |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 * Copyright (c) Facebook, Inc. and its affiliates. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
6 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
7 * This source code is licensed under the MIT license found in the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
8 * LICENSE file in the root directory of this source tree. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 'use strict'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
13 if (process.env.NODE_ENV !== "production") { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
14 (function() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
15 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
16 'use strict'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
18 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
19 if ( |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
20 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
21 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
22 'function' |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
23 ) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
24 __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
25 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
26 var ReactVersion = '18.3.1'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
27 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
28 // ATTENTION |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
29 // When adding new symbols to this file, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
30 // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
31 // The Symbol used to tag the ReactElement-like types. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
32 var REACT_ELEMENT_TYPE = Symbol.for('react.element'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
33 var REACT_PORTAL_TYPE = Symbol.for('react.portal'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
34 var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
35 var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
36 var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
37 var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
38 var REACT_CONTEXT_TYPE = Symbol.for('react.context'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
39 var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
40 var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
41 var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
42 var REACT_MEMO_TYPE = Symbol.for('react.memo'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
43 var REACT_LAZY_TYPE = Symbol.for('react.lazy'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
44 var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
45 var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
46 var FAUX_ITERATOR_SYMBOL = '@@iterator'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
47 function getIteratorFn(maybeIterable) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
48 if (maybeIterable === null || typeof maybeIterable !== 'object') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
49 return null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
50 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
51 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
52 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
53 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
54 if (typeof maybeIterator === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
55 return maybeIterator; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
56 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
57 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
58 return null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
59 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
60 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
61 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
62 * Keeps track of the current dispatcher. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
63 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
64 var ReactCurrentDispatcher = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
65 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
66 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
67 * @type {ReactComponent} |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
68 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
69 current: null |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
70 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
71 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
72 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
73 * Keeps track of the current batch's configuration such as how long an update |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
74 * should suspend for if it needs to. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
75 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
76 var ReactCurrentBatchConfig = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
77 transition: null |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
78 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
79 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
80 var ReactCurrentActQueue = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
81 current: null, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
82 // Used to reproduce behavior of `batchedUpdates` in legacy mode. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
83 isBatchingLegacy: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
84 didScheduleLegacyUpdate: false |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
85 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
86 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
87 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
88 * Keeps track of the current owner. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
89 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
90 * The current owner is the component who should own any components that are |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
91 * currently being constructed. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
92 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
93 var ReactCurrentOwner = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
94 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
95 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
96 * @type {ReactComponent} |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
97 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
98 current: null |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
99 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
100 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
101 var ReactDebugCurrentFrame = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
102 var currentExtraStackFrame = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
103 function setExtraStackFrame(stack) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
104 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
105 currentExtraStackFrame = stack; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
106 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
107 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
108 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
109 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
110 ReactDebugCurrentFrame.setExtraStackFrame = function (stack) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
111 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
112 currentExtraStackFrame = stack; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
113 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
114 }; // Stack implementation injected by the current renderer. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
115 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
116 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
117 ReactDebugCurrentFrame.getCurrentStack = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
118 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
119 ReactDebugCurrentFrame.getStackAddendum = function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
120 var stack = ''; // Add an extra top frame while an element is being validated |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
121 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
122 if (currentExtraStackFrame) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
123 stack += currentExtraStackFrame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
124 } // Delegate to the injected renderer-specific implementation |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
125 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
126 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
127 var impl = ReactDebugCurrentFrame.getCurrentStack; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
128 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
129 if (impl) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
130 stack += impl() || ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
131 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
132 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
133 return stack; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
134 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
135 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
136 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
137 // ----------------------------------------------------------------------------- |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
138 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
139 var enableScopeAPI = false; // Experimental Create Event Handle API. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
140 var enableCacheElement = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
141 var enableTransitionTracing = false; // No known bugs, but needs performance testing |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
142 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
143 var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
144 // stuff. Intended to enable React core members to more easily debug scheduling |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
145 // issues in DEV builds. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
146 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
147 var enableDebugTracing = false; // Track which Fiber(s) schedule render work. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
148 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
149 var ReactSharedInternals = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
150 ReactCurrentDispatcher: ReactCurrentDispatcher, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
151 ReactCurrentBatchConfig: ReactCurrentBatchConfig, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
152 ReactCurrentOwner: ReactCurrentOwner |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
153 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
154 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
155 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
156 ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
157 ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
158 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
159 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
160 // by calls to these methods by a Babel plugin. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
161 // |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
162 // In PROD (or in packages without access to React internals), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
163 // they are left as they are instead. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
164 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
165 function warn(format) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
166 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
167 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
168 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
169 args[_key - 1] = arguments[_key]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
170 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
171 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
172 printWarning('warn', format, args); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
173 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
174 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
175 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
176 function error(format) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
177 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
178 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
179 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
180 args[_key2 - 1] = arguments[_key2]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
181 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
182 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
183 printWarning('error', format, args); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
184 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
185 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
186 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
187 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
188 function printWarning(level, format, args) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
189 // When changing this logic, you might want to also |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
190 // update consoleWithStackDev.www.js as well. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
191 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
192 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
193 var stack = ReactDebugCurrentFrame.getStackAddendum(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
194 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
195 if (stack !== '') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
196 format += '%s'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
197 args = args.concat([stack]); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
198 } // eslint-disable-next-line react-internal/safe-string-coercion |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
199 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
200 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
201 var argsWithFormat = args.map(function (item) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
202 return String(item); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
203 }); // Careful: RN currently depends on this prefix |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
204 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
205 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
206 // breaks IE9: https://github.com/facebook/react/issues/13610 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
207 // eslint-disable-next-line react-internal/no-production-logging |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
208 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
209 Function.prototype.apply.call(console[level], console, argsWithFormat); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
210 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
211 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
212 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
213 var didWarnStateUpdateForUnmountedComponent = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
214 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
215 function warnNoop(publicInstance, callerName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
216 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
217 var _constructor = publicInstance.constructor; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
218 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
219 var warningKey = componentName + "." + callerName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
220 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
221 if (didWarnStateUpdateForUnmountedComponent[warningKey]) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
222 return; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
223 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
224 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
225 error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
226 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
227 didWarnStateUpdateForUnmountedComponent[warningKey] = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
228 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
229 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
230 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
231 * This is the abstract API for an update queue. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
232 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
233 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
234 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
235 var ReactNoopUpdateQueue = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
236 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
237 * Checks whether or not this composite component is mounted. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
238 * @param {ReactClass} publicInstance The instance we want to test. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
239 * @return {boolean} True if mounted, false otherwise. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
240 * @protected |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
241 * @final |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
242 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
243 isMounted: function (publicInstance) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
244 return false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
245 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
246 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
247 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
248 * Forces an update. This should only be invoked when it is known with |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
249 * certainty that we are **not** in a DOM transaction. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
250 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
251 * You may want to call this when you know that some deeper aspect of the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
252 * component's state has changed but `setState` was not called. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
253 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
254 * This will not invoke `shouldComponentUpdate`, but it will invoke |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
255 * `componentWillUpdate` and `componentDidUpdate`. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
256 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
257 * @param {ReactClass} publicInstance The instance that should rerender. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
258 * @param {?function} callback Called after component is updated. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
259 * @param {?string} callerName name of the calling function in the public API. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
260 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
261 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
262 enqueueForceUpdate: function (publicInstance, callback, callerName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
263 warnNoop(publicInstance, 'forceUpdate'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
264 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
265 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
266 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
267 * Replaces all of the state. Always use this or `setState` to mutate state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
268 * You should treat `this.state` as immutable. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
269 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
270 * There is no guarantee that `this.state` will be immediately updated, so |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
271 * accessing `this.state` after calling this method may return the old value. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
272 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
273 * @param {ReactClass} publicInstance The instance that should rerender. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
274 * @param {object} completeState Next state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
275 * @param {?function} callback Called after component is updated. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
276 * @param {?string} callerName name of the calling function in the public API. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
277 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
278 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
279 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
280 warnNoop(publicInstance, 'replaceState'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
281 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
282 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
283 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
284 * Sets a subset of the state. This only exists because _pendingState is |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
285 * internal. This provides a merging strategy that is not available to deep |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
286 * properties which is confusing. TODO: Expose pendingState or don't use it |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
287 * during the merge. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
288 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
289 * @param {ReactClass} publicInstance The instance that should rerender. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
290 * @param {object} partialState Next partial state to be merged with state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
291 * @param {?function} callback Called after component is updated. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
292 * @param {?string} Name of the calling function in the public API. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
293 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
294 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
295 enqueueSetState: function (publicInstance, partialState, callback, callerName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
296 warnNoop(publicInstance, 'setState'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
297 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
298 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
299 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
300 var assign = Object.assign; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
301 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
302 var emptyObject = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
303 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
304 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
305 Object.freeze(emptyObject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
306 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
307 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
308 * Base class helpers for the updating state of a component. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
309 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
310 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
311 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
312 function Component(props, context, updater) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
313 this.props = props; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
314 this.context = context; // If a component has string refs, we will assign a different object later. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
315 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
316 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
317 // renderer. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
318 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
319 this.updater = updater || ReactNoopUpdateQueue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
320 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
321 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
322 Component.prototype.isReactComponent = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
323 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
324 * Sets a subset of the state. Always use this to mutate |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
325 * state. You should treat `this.state` as immutable. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
326 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
327 * There is no guarantee that `this.state` will be immediately updated, so |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
328 * accessing `this.state` after calling this method may return the old value. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
329 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
330 * There is no guarantee that calls to `setState` will run synchronously, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
331 * as they may eventually be batched together. You can provide an optional |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
332 * callback that will be executed when the call to setState is actually |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
333 * completed. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
334 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
335 * When a function is provided to setState, it will be called at some point in |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
336 * the future (not synchronously). It will be called with the up to date |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
337 * component arguments (state, props, context). These values can be different |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
338 * from this.* because your function may be called after receiveProps but before |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
339 * shouldComponentUpdate, and this new state, props, and context will not yet be |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
340 * assigned to this. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
341 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
342 * @param {object|function} partialState Next partial state or function to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
343 * produce next partial state to be merged with current state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
344 * @param {?function} callback Called after state is updated. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
345 * @final |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
346 * @protected |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
347 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
348 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
349 Component.prototype.setState = function (partialState, callback) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
350 if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
351 throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
352 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
353 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
354 this.updater.enqueueSetState(this, partialState, callback, 'setState'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
355 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
356 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
357 * Forces an update. This should only be invoked when it is known with |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
358 * certainty that we are **not** in a DOM transaction. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
359 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
360 * You may want to call this when you know that some deeper aspect of the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
361 * component's state has changed but `setState` was not called. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
362 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
363 * This will not invoke `shouldComponentUpdate`, but it will invoke |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
364 * `componentWillUpdate` and `componentDidUpdate`. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
365 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
366 * @param {?function} callback Called after update is complete. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
367 * @final |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
368 * @protected |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
369 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
370 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
371 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
372 Component.prototype.forceUpdate = function (callback) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
373 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
374 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
375 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
376 * Deprecated APIs. These APIs used to exist on classic React classes but since |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
377 * we would like to deprecate them, we're not going to move them over to this |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
378 * modern base class. Instead, we define a getter that warns if it's accessed. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
379 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
380 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
381 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
382 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
383 var deprecatedAPIs = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
384 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
385 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
386 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
387 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
388 var defineDeprecationWarning = function (methodName, info) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
389 Object.defineProperty(Component.prototype, methodName, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
390 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
391 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
392 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
393 return undefined; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
394 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
395 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
396 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
397 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
398 for (var fnName in deprecatedAPIs) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
399 if (deprecatedAPIs.hasOwnProperty(fnName)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
400 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
401 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
402 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
403 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
404 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
405 function ComponentDummy() {} |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
406 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
407 ComponentDummy.prototype = Component.prototype; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
408 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
409 * Convenience component with default shallow equality check for sCU. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
410 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
411 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
412 function PureComponent(props, context, updater) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
413 this.props = props; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
414 this.context = context; // If a component has string refs, we will assign a different object later. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
415 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
416 this.refs = emptyObject; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
417 this.updater = updater || ReactNoopUpdateQueue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
418 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
419 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
420 var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
421 pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
422 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
423 assign(pureComponentPrototype, Component.prototype); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
424 pureComponentPrototype.isPureReactComponent = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
425 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
426 // an immutable object with a single mutable value |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
427 function createRef() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
428 var refObject = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
429 current: null |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
430 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
431 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
432 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
433 Object.seal(refObject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
434 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
435 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
436 return refObject; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
437 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
438 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
439 var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
440 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
441 function isArray(a) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
442 return isArrayImpl(a); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
443 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
444 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
445 /* |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
446 * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
447 * and Temporal.* types. See https://github.com/facebook/react/pull/22064. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
448 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
449 * The functions in this module will throw an easier-to-understand, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
450 * easier-to-debug exception with a clear errors message message explaining the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
451 * problem. (Instead of a confusing exception thrown inside the implementation |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
452 * of the `value` object). |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
453 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
454 // $FlowFixMe only called in DEV, so void return is not possible. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
455 function typeName(value) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
456 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
457 // toStringTag is needed for namespaced types like Temporal.Instant |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
458 var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
459 var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
460 return type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
461 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
462 } // $FlowFixMe only called in DEV, so void return is not possible. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
463 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
464 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
465 function willCoercionThrow(value) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
466 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
467 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
468 testStringCoercion(value); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
469 return false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
470 } catch (e) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
471 return true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
472 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
473 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
474 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
475 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
476 function testStringCoercion(value) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
477 // If you ended up here by following an exception call stack, here's what's |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
478 // happened: you supplied an object or symbol value to React (as a prop, key, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
479 // DOM attribute, CSS property, string ref, etc.) and when React tried to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
480 // coerce it to a string using `'' + value`, an exception was thrown. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
481 // |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
482 // The most common types that will cause this exception are `Symbol` instances |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
483 // and Temporal objects like `Temporal.Instant`. But any object that has a |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
484 // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
485 // exception. (Library authors do this to prevent users from using built-in |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
486 // numeric operators like `+` or comparison operators like `>=` because custom |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
487 // methods are needed to perform accurate arithmetic or comparison.) |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
488 // |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
489 // To fix the problem, coerce this object or symbol value to a string before |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
490 // passing it to React. The most reliable way is usually `String(value)`. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
491 // |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
492 // To find which value is throwing, check the browser or debugger console. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
493 // Before this exception was thrown, there should be `console.error` output |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
494 // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
495 // problem and how that type was used: key, atrribute, input value prop, etc. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
496 // In most cases, this console output also shows the component and its |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
497 // ancestor components where the exception happened. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
498 // |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
499 // eslint-disable-next-line react-internal/safe-string-coercion |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
500 return '' + value; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
501 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
502 function checkKeyStringCoercion(value) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
503 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
504 if (willCoercionThrow(value)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
505 error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value)); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
506 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
507 return testStringCoercion(value); // throw (to help callers find troubleshooting comments) |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
508 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
509 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
510 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
511 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
512 function getWrappedName(outerType, innerType, wrapperName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
513 var displayName = outerType.displayName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
514 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
515 if (displayName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
516 return displayName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
517 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
518 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
519 var functionName = innerType.displayName || innerType.name || ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
520 return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
521 } // Keep in sync with react-reconciler/getComponentNameFromFiber |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
522 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
523 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
524 function getContextName(type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
525 return type.displayName || 'Context'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
526 } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
527 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
528 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
529 function getComponentNameFromType(type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
530 if (type == null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
531 // Host root, text node or just invalid type. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
532 return null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
533 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
534 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
535 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
536 if (typeof type.tag === 'number') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
537 error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
538 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
539 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
540 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
541 if (typeof type === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
542 return type.displayName || type.name || null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
543 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
544 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
545 if (typeof type === 'string') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
546 return type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
547 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
548 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
549 switch (type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
550 case REACT_FRAGMENT_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
551 return 'Fragment'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
552 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
553 case REACT_PORTAL_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
554 return 'Portal'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
555 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
556 case REACT_PROFILER_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
557 return 'Profiler'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
558 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
559 case REACT_STRICT_MODE_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
560 return 'StrictMode'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
561 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
562 case REACT_SUSPENSE_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
563 return 'Suspense'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
564 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
565 case REACT_SUSPENSE_LIST_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
566 return 'SuspenseList'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
567 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
568 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
569 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
570 if (typeof type === 'object') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
571 switch (type.$$typeof) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
572 case REACT_CONTEXT_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
573 var context = type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
574 return getContextName(context) + '.Consumer'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
575 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
576 case REACT_PROVIDER_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
577 var provider = type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
578 return getContextName(provider._context) + '.Provider'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
579 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
580 case REACT_FORWARD_REF_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
581 return getWrappedName(type, type.render, 'ForwardRef'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
582 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
583 case REACT_MEMO_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
584 var outerName = type.displayName || null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
585 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
586 if (outerName !== null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
587 return outerName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
588 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
589 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
590 return getComponentNameFromType(type.type) || 'Memo'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
591 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
592 case REACT_LAZY_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
593 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
594 var lazyComponent = type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
595 var payload = lazyComponent._payload; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
596 var init = lazyComponent._init; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
597 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
598 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
599 return getComponentNameFromType(init(payload)); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
600 } catch (x) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
601 return null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
602 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
603 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
604 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
605 // eslint-disable-next-line no-fallthrough |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
606 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
607 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
608 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
609 return null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
610 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
611 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
612 var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
613 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
614 var RESERVED_PROPS = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
615 key: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
616 ref: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
617 __self: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
618 __source: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
619 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
620 var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
621 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
622 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
623 didWarnAboutStringRefs = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
624 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
625 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
626 function hasValidRef(config) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
627 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
628 if (hasOwnProperty.call(config, 'ref')) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
629 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
630 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
631 if (getter && getter.isReactWarning) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
632 return false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
633 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
634 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
635 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
636 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
637 return config.ref !== undefined; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
638 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
639 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
640 function hasValidKey(config) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
641 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
642 if (hasOwnProperty.call(config, 'key')) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
643 var getter = Object.getOwnPropertyDescriptor(config, 'key').get; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
644 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
645 if (getter && getter.isReactWarning) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
646 return false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
647 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
648 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
649 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
650 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
651 return config.key !== undefined; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
652 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
653 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
654 function defineKeyPropWarningGetter(props, displayName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
655 var warnAboutAccessingKey = function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
656 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
657 if (!specialPropKeyWarningShown) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
658 specialPropKeyWarningShown = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
659 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
660 error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
661 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
662 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
663 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
664 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
665 warnAboutAccessingKey.isReactWarning = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
666 Object.defineProperty(props, 'key', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
667 get: warnAboutAccessingKey, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
668 configurable: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
669 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
670 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
671 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
672 function defineRefPropWarningGetter(props, displayName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
673 var warnAboutAccessingRef = function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
674 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
675 if (!specialPropRefWarningShown) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
676 specialPropRefWarningShown = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
677 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
678 error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
679 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
680 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
681 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
682 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
683 warnAboutAccessingRef.isReactWarning = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
684 Object.defineProperty(props, 'ref', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
685 get: warnAboutAccessingRef, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
686 configurable: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
687 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
688 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
689 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
690 function warnIfStringRefCannotBeAutoConverted(config) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
691 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
692 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
693 var componentName = getComponentNameFromType(ReactCurrentOwner.current.type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
694 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
695 if (!didWarnAboutStringRefs[componentName]) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
696 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
697 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
698 didWarnAboutStringRefs[componentName] = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
699 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
700 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
701 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
702 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
703 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
704 * Factory method to create a new React element. This no longer adheres to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
705 * the class pattern, so do not use new to call it. Also, instanceof check |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
706 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
707 * if something is a React Element. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
708 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
709 * @param {*} type |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
710 * @param {*} props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
711 * @param {*} key |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
712 * @param {string|object} ref |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
713 * @param {*} owner |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
714 * @param {*} self A *temporary* helper to detect places where `this` is |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
715 * different from the `owner` when React.createElement is called, so that we |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
716 * can warn. We want to get rid of owner and replace string `ref`s with arrow |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
717 * functions, and as long as `this` and owner are the same, there will be no |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
718 * change in behavior. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
719 * @param {*} source An annotation object (added by a transpiler or otherwise) |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
720 * indicating filename, line number, and/or other information. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
721 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
722 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
723 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
724 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
725 var ReactElement = function (type, key, ref, self, source, owner, props) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
726 var element = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
727 // This tag allows us to uniquely identify this as a React Element |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
728 $$typeof: REACT_ELEMENT_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
729 // Built-in properties that belong on the element |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
730 type: type, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
731 key: key, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
732 ref: ref, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
733 props: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
734 // Record the component responsible for creating this element. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
735 _owner: owner |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
736 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
737 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
738 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
739 // The validation flag is currently mutative. We put it on |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
740 // an external backing store so that we can freeze the whole object. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
741 // This can be replaced with a WeakMap once they are implemented in |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
742 // commonly used development environments. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
743 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
744 // the validation flag non-enumerable (where possible, which should |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
745 // include every environment we run tests in), so the test framework |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
746 // ignores it. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
747 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
748 Object.defineProperty(element._store, 'validated', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
749 configurable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
750 enumerable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
751 writable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
752 value: false |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
753 }); // self and source are DEV only properties. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
754 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
755 Object.defineProperty(element, '_self', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
756 configurable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
757 enumerable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
758 writable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
759 value: self |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
760 }); // Two elements created in two different places should be considered |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
761 // equal for testing purposes and therefore we hide it from enumeration. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
762 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
763 Object.defineProperty(element, '_source', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
764 configurable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
765 enumerable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
766 writable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
767 value: source |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
768 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
769 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
770 if (Object.freeze) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
771 Object.freeze(element.props); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
772 Object.freeze(element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
773 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
774 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
775 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
776 return element; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
777 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
778 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
779 * Create and return a new ReactElement of the given type. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
780 * See https://reactjs.org/docs/react-api.html#createelement |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
781 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
782 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
783 function createElement(type, config, children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
784 var propName; // Reserved names are extracted |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
785 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
786 var props = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
787 var key = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
788 var ref = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
789 var self = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
790 var source = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
791 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
792 if (config != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
793 if (hasValidRef(config)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
794 ref = config.ref; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
795 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
796 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
797 warnIfStringRefCannotBeAutoConverted(config); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
798 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
799 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
800 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
801 if (hasValidKey(config)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
802 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
803 checkKeyStringCoercion(config.key); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
804 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
805 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
806 key = '' + config.key; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
807 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
808 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
809 self = config.__self === undefined ? null : config.__self; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
810 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
811 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
812 for (propName in config) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
813 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
814 props[propName] = config[propName]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
815 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
816 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
817 } // Children can be more than one argument, and those are transferred onto |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
818 // the newly allocated props object. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
819 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
820 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
821 var childrenLength = arguments.length - 2; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
822 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
823 if (childrenLength === 1) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
824 props.children = children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
825 } else if (childrenLength > 1) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
826 var childArray = Array(childrenLength); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
827 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
828 for (var i = 0; i < childrenLength; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
829 childArray[i] = arguments[i + 2]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
830 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
831 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
832 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
833 if (Object.freeze) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
834 Object.freeze(childArray); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
835 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
836 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
837 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
838 props.children = childArray; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
839 } // Resolve default props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
840 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
841 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
842 if (type && type.defaultProps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
843 var defaultProps = type.defaultProps; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
844 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
845 for (propName in defaultProps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
846 if (props[propName] === undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
847 props[propName] = defaultProps[propName]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
848 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
849 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
850 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
851 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
852 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
853 if (key || ref) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
854 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
855 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
856 if (key) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
857 defineKeyPropWarningGetter(props, displayName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
858 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
859 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
860 if (ref) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
861 defineRefPropWarningGetter(props, displayName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
862 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
863 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
864 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
865 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
866 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
867 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
868 function cloneAndReplaceKey(oldElement, newKey) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
869 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
870 return newElement; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
871 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
872 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
873 * Clone and return a new ReactElement using element as the starting point. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
874 * See https://reactjs.org/docs/react-api.html#cloneelement |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
875 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
876 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
877 function cloneElement(element, config, children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
878 if (element === null || element === undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
879 throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + "."); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
880 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
881 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
882 var propName; // Original props are copied |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
883 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
884 var props = assign({}, element.props); // Reserved names are extracted |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
885 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
886 var key = element.key; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
887 var ref = element.ref; // Self is preserved since the owner is preserved. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
888 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
889 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
890 // transpiler, and the original source is probably a better indicator of the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
891 // true owner. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
892 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
893 var source = element._source; // Owner will be preserved, unless ref is overridden |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
894 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
895 var owner = element._owner; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
896 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
897 if (config != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
898 if (hasValidRef(config)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
899 // Silently steal the ref from the parent. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
900 ref = config.ref; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
901 owner = ReactCurrentOwner.current; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
902 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
903 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
904 if (hasValidKey(config)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
905 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
906 checkKeyStringCoercion(config.key); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
907 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
908 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
909 key = '' + config.key; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
910 } // Remaining properties override existing props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
911 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
912 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
913 var defaultProps; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
914 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
915 if (element.type && element.type.defaultProps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
916 defaultProps = element.type.defaultProps; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
917 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
918 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
919 for (propName in config) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
920 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
921 if (config[propName] === undefined && defaultProps !== undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
922 // Resolve default props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
923 props[propName] = defaultProps[propName]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
924 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
925 props[propName] = config[propName]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
926 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
927 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
928 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
929 } // Children can be more than one argument, and those are transferred onto |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
930 // the newly allocated props object. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
931 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
932 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
933 var childrenLength = arguments.length - 2; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
934 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
935 if (childrenLength === 1) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
936 props.children = children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
937 } else if (childrenLength > 1) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
938 var childArray = Array(childrenLength); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
939 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
940 for (var i = 0; i < childrenLength; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
941 childArray[i] = arguments[i + 2]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
942 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
943 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
944 props.children = childArray; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
945 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
946 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
947 return ReactElement(element.type, key, ref, self, source, owner, props); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
948 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
949 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
950 * Verifies the object is a ReactElement. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
951 * See https://reactjs.org/docs/react-api.html#isvalidelement |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
952 * @param {?object} object |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
953 * @return {boolean} True if `object` is a ReactElement. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
954 * @final |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
955 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
956 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
957 function isValidElement(object) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
958 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
959 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
960 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
961 var SEPARATOR = '.'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
962 var SUBSEPARATOR = ':'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
963 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
964 * Escape and wrap key so it is safe to use as a reactid |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
965 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
966 * @param {string} key to be escaped. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
967 * @return {string} the escaped key. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
968 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
969 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
970 function escape(key) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
971 var escapeRegex = /[=:]/g; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
972 var escaperLookup = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
973 '=': '=0', |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
974 ':': '=2' |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
975 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
976 var escapedString = key.replace(escapeRegex, function (match) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
977 return escaperLookup[match]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
978 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
979 return '$' + escapedString; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
980 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
981 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
982 * TODO: Test that a single child and an array with one item have the same key |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
983 * pattern. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
984 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
985 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
986 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
987 var didWarnAboutMaps = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
988 var userProvidedKeyEscapeRegex = /\/+/g; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
989 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
990 function escapeUserProvidedKey(text) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
991 return text.replace(userProvidedKeyEscapeRegex, '$&/'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
992 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
993 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
994 * Generate a key string that identifies a element within a set. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
995 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
996 * @param {*} element A element that could contain a manual key. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
997 * @param {number} index Index that is used if a manual key is not provided. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
998 * @return {string} |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
999 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1000 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1001 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1002 function getElementKey(element, index) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1003 // Do some typechecking here since we call this blindly. We want to ensure |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1004 // that we don't block potential future ES APIs. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1005 if (typeof element === 'object' && element !== null && element.key != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1006 // Explicit key |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1007 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1008 checkKeyStringCoercion(element.key); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1009 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1010 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1011 return escape('' + element.key); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1012 } // Implicit key determined by the index in the set |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1013 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1014 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1015 return index.toString(36); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1016 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1017 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1018 function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1019 var type = typeof children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1020 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1021 if (type === 'undefined' || type === 'boolean') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1022 // All of the above are perceived as null. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1023 children = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1024 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1025 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1026 var invokeCallback = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1027 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1028 if (children === null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1029 invokeCallback = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1030 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1031 switch (type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1032 case 'string': |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1033 case 'number': |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1034 invokeCallback = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1035 break; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1036 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1037 case 'object': |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1038 switch (children.$$typeof) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1039 case REACT_ELEMENT_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1040 case REACT_PORTAL_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1041 invokeCallback = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1042 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1043 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1044 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1045 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1046 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1047 if (invokeCallback) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1048 var _child = children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1049 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1050 // so that it's consistent if the number of children grows: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1051 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1052 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1053 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1054 if (isArray(mappedChild)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1055 var escapedChildKey = ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1056 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1057 if (childKey != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1058 escapedChildKey = escapeUserProvidedKey(childKey) + '/'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1059 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1060 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1061 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1062 return c; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1063 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1064 } else if (mappedChild != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1065 if (isValidElement(mappedChild)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1066 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1067 // The `if` statement here prevents auto-disabling of the safe |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1068 // coercion ESLint rule, so we must manually disable it below. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1069 // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1070 if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1071 checkKeyStringCoercion(mappedChild.key); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1072 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1073 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1074 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1075 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1076 // traverseAllChildren used to do for objects as children |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1077 escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1078 mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1079 // eslint-disable-next-line react-internal/safe-string-coercion |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1080 escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1081 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1082 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1083 array.push(mappedChild); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1084 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1085 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1086 return 1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1087 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1088 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1089 var child; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1090 var nextName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1091 var subtreeCount = 0; // Count of children found in the current subtree. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1092 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1093 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1094 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1095 if (isArray(children)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1096 for (var i = 0; i < children.length; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1097 child = children[i]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1098 nextName = nextNamePrefix + getElementKey(child, i); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1099 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1100 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1101 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1102 var iteratorFn = getIteratorFn(children); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1103 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1104 if (typeof iteratorFn === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1105 var iterableChildren = children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1106 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1107 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1108 // Warn about using Maps as children |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1109 if (iteratorFn === iterableChildren.entries) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1110 if (!didWarnAboutMaps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1111 warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1112 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1113 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1114 didWarnAboutMaps = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1115 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1116 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1117 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1118 var iterator = iteratorFn.call(iterableChildren); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1119 var step; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1120 var ii = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1121 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1122 while (!(step = iterator.next()).done) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1123 child = step.value; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1124 nextName = nextNamePrefix + getElementKey(child, ii++); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1125 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1126 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1127 } else if (type === 'object') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1128 // eslint-disable-next-line react-internal/safe-string-coercion |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1129 var childrenString = String(children); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1130 throw new Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1131 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1132 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1133 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1134 return subtreeCount; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1135 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1136 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1137 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1138 * Maps children that are typically specified as `props.children`. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1139 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1140 * See https://reactjs.org/docs/react-api.html#reactchildrenmap |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1141 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1142 * The provided mapFunction(child, index) will be called for each |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1143 * leaf child. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1144 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1145 * @param {?*} children Children tree container. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1146 * @param {function(*, int)} func The map function. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1147 * @param {*} context Context for mapFunction. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1148 * @return {object} Object containing the ordered map of results. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1149 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1150 function mapChildren(children, func, context) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1151 if (children == null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1152 return children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1153 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1154 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1155 var result = []; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1156 var count = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1157 mapIntoArray(children, result, '', '', function (child) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1158 return func.call(context, child, count++); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1159 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1160 return result; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1161 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1162 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1163 * Count the number of children that are typically specified as |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1164 * `props.children`. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1165 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1166 * See https://reactjs.org/docs/react-api.html#reactchildrencount |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1167 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1168 * @param {?*} children Children tree container. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1169 * @return {number} The number of children. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1170 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1171 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1172 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1173 function countChildren(children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1174 var n = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1175 mapChildren(children, function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1176 n++; // Don't return anything |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1177 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1178 return n; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1179 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1180 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1181 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1182 * Iterates through children that are typically specified as `props.children`. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1183 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1184 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1185 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1186 * The provided forEachFunc(child, index) will be called for each |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1187 * leaf child. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1188 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1189 * @param {?*} children Children tree container. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1190 * @param {function(*, int)} forEachFunc |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1191 * @param {*} forEachContext Context for forEachContext. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1192 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1193 function forEachChildren(children, forEachFunc, forEachContext) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1194 mapChildren(children, function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1195 forEachFunc.apply(this, arguments); // Don't return anything. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1196 }, forEachContext); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1197 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1198 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1199 * Flatten a children object (typically specified as `props.children`) and |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1200 * return an array with appropriately re-keyed children. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1201 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1202 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1203 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1204 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1205 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1206 function toArray(children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1207 return mapChildren(children, function (child) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1208 return child; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1209 }) || []; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1210 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1211 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1212 * Returns the first child in a collection of children and verifies that there |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1213 * is only one child in the collection. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1214 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1215 * See https://reactjs.org/docs/react-api.html#reactchildrenonly |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1216 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1217 * The current implementation of this function assumes that a single child gets |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1218 * passed without a wrapper, but the purpose of this helper function is to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1219 * abstract away the particular structure of children. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1220 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1221 * @param {?object} children Child collection structure. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1222 * @return {ReactElement} The first and only `ReactElement` contained in the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1223 * structure. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1224 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1225 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1226 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1227 function onlyChild(children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1228 if (!isValidElement(children)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1229 throw new Error('React.Children.only expected to receive a single React element child.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1230 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1231 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1232 return children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1233 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1234 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1235 function createContext(defaultValue) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1236 // TODO: Second argument used to be an optional `calculateChangedBits` |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1237 // function. Warn to reserve for future use? |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1238 var context = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1239 $$typeof: REACT_CONTEXT_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1240 // As a workaround to support multiple concurrent renderers, we categorize |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1241 // some renderers as primary and others as secondary. We only expect |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1242 // there to be two concurrent renderers at most: React Native (primary) and |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1243 // Fabric (secondary); React DOM (primary) and React ART (secondary). |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1244 // Secondary renderers store their context values on separate fields. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1245 _currentValue: defaultValue, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1246 _currentValue2: defaultValue, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1247 // Used to track how many concurrent renderers this context currently |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1248 // supports within in a single renderer. Such as parallel server rendering. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1249 _threadCount: 0, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1250 // These are circular |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1251 Provider: null, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1252 Consumer: null, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1253 // Add these to use same hidden class in VM as ServerContext |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1254 _defaultValue: null, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1255 _globalName: null |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1256 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1257 context.Provider = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1258 $$typeof: REACT_PROVIDER_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1259 _context: context |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1260 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1261 var hasWarnedAboutUsingNestedContextConsumers = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1262 var hasWarnedAboutUsingConsumerProvider = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1263 var hasWarnedAboutDisplayNameOnConsumer = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1264 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1265 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1266 // A separate object, but proxies back to the original context object for |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1267 // backwards compatibility. It has a different $$typeof, so we can properly |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1268 // warn for the incorrect usage of Context as a Consumer. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1269 var Consumer = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1270 $$typeof: REACT_CONTEXT_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1271 _context: context |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1272 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1273 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1274 Object.defineProperties(Consumer, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1275 Provider: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1276 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1277 if (!hasWarnedAboutUsingConsumerProvider) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1278 hasWarnedAboutUsingConsumerProvider = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1279 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1280 error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1281 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1282 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1283 return context.Provider; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1284 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1285 set: function (_Provider) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1286 context.Provider = _Provider; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1287 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1288 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1289 _currentValue: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1290 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1291 return context._currentValue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1292 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1293 set: function (_currentValue) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1294 context._currentValue = _currentValue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1295 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1296 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1297 _currentValue2: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1298 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1299 return context._currentValue2; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1300 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1301 set: function (_currentValue2) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1302 context._currentValue2 = _currentValue2; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1303 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1304 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1305 _threadCount: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1306 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1307 return context._threadCount; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1308 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1309 set: function (_threadCount) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1310 context._threadCount = _threadCount; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1311 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1312 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1313 Consumer: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1314 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1315 if (!hasWarnedAboutUsingNestedContextConsumers) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1316 hasWarnedAboutUsingNestedContextConsumers = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1317 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1318 error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1319 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1320 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1321 return context.Consumer; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1322 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1323 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1324 displayName: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1325 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1326 return context.displayName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1327 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1328 set: function (displayName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1329 if (!hasWarnedAboutDisplayNameOnConsumer) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1330 warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1331 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1332 hasWarnedAboutDisplayNameOnConsumer = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1333 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1334 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1335 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1336 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1337 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1338 context.Consumer = Consumer; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1339 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1340 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1341 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1342 context._currentRenderer = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1343 context._currentRenderer2 = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1344 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1345 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1346 return context; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1347 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1348 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1349 var Uninitialized = -1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1350 var Pending = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1351 var Resolved = 1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1352 var Rejected = 2; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1353 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1354 function lazyInitializer(payload) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1355 if (payload._status === Uninitialized) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1356 var ctor = payload._result; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1357 var thenable = ctor(); // Transition to the next state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1358 // This might throw either because it's missing or throws. If so, we treat it |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1359 // as still uninitialized and try again next time. Which is the same as what |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1360 // happens if the ctor or any wrappers processing the ctor throws. This might |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1361 // end up fixing it if the resolution was a concurrency bug. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1362 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1363 thenable.then(function (moduleObject) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1364 if (payload._status === Pending || payload._status === Uninitialized) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1365 // Transition to the next state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1366 var resolved = payload; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1367 resolved._status = Resolved; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1368 resolved._result = moduleObject; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1369 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1370 }, function (error) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1371 if (payload._status === Pending || payload._status === Uninitialized) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1372 // Transition to the next state. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1373 var rejected = payload; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1374 rejected._status = Rejected; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1375 rejected._result = error; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1376 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1377 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1378 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1379 if (payload._status === Uninitialized) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1380 // In case, we're still uninitialized, then we're waiting for the thenable |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1381 // to resolve. Set it as pending in the meantime. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1382 var pending = payload; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1383 pending._status = Pending; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1384 pending._result = thenable; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1385 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1386 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1387 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1388 if (payload._status === Resolved) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1389 var moduleObject = payload._result; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1390 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1391 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1392 if (moduleObject === undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1393 error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1394 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1395 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1396 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1397 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1398 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1399 if (!('default' in moduleObject)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1400 error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1401 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1402 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1403 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1404 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1405 return moduleObject.default; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1406 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1407 throw payload._result; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1408 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1409 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1410 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1411 function lazy(ctor) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1412 var payload = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1413 // We use these fields to store the result. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1414 _status: Uninitialized, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1415 _result: ctor |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1416 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1417 var lazyType = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1418 $$typeof: REACT_LAZY_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1419 _payload: payload, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1420 _init: lazyInitializer |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1421 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1422 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1423 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1424 // In production, this would just set it on the object. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1425 var defaultProps; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1426 var propTypes; // $FlowFixMe |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1427 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1428 Object.defineProperties(lazyType, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1429 defaultProps: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1430 configurable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1431 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1432 return defaultProps; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1433 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1434 set: function (newDefaultProps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1435 error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1436 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1437 defaultProps = newDefaultProps; // Match production behavior more closely: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1438 // $FlowFixMe |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1439 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1440 Object.defineProperty(lazyType, 'defaultProps', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1441 enumerable: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1442 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1443 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1444 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1445 propTypes: { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1446 configurable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1447 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1448 return propTypes; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1449 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1450 set: function (newPropTypes) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1451 error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1452 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1453 propTypes = newPropTypes; // Match production behavior more closely: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1454 // $FlowFixMe |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1455 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1456 Object.defineProperty(lazyType, 'propTypes', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1457 enumerable: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1458 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1459 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1460 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1461 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1462 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1463 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1464 return lazyType; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1465 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1466 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1467 function forwardRef(render) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1468 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1469 if (render != null && render.$$typeof === REACT_MEMO_TYPE) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1470 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1471 } else if (typeof render !== 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1472 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1473 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1474 if (render.length !== 0 && render.length !== 2) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1475 error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1476 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1477 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1478 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1479 if (render != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1480 if (render.defaultProps != null || render.propTypes != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1481 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1482 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1483 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1484 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1485 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1486 var elementType = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1487 $$typeof: REACT_FORWARD_REF_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1488 render: render |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1489 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1490 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1491 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1492 var ownName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1493 Object.defineProperty(elementType, 'displayName', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1494 enumerable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1495 configurable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1496 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1497 return ownName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1498 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1499 set: function (name) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1500 ownName = name; // The inner component shouldn't inherit this display name in most cases, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1501 // because the component may be used elsewhere. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1502 // But it's nice for anonymous functions to inherit the name, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1503 // so that our component-stack generation logic will display their frames. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1504 // An anonymous function generally suggests a pattern like: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1505 // React.forwardRef((props, ref) => {...}); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1506 // This kind of inner function is not used elsewhere so the side effect is okay. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1507 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1508 if (!render.name && !render.displayName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1509 render.displayName = name; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1510 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1511 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1512 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1513 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1514 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1515 return elementType; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1516 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1517 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1518 var REACT_MODULE_REFERENCE; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1519 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1520 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1521 REACT_MODULE_REFERENCE = Symbol.for('react.module.reference'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1522 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1523 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1524 function isValidElementType(type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1525 if (typeof type === 'string' || typeof type === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1526 return true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1527 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1528 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1529 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1530 if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1531 return true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1532 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1533 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1534 if (typeof type === 'object' && type !== null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1535 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1536 // types supported by any Flight configuration anywhere since |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1537 // we don't know which Flight build this will end up being used |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1538 // with. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1539 type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1540 return true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1541 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1542 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1543 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1544 return false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1545 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1546 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1547 function memo(type, compare) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1548 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1549 if (!isValidElementType(type)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1550 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1551 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1552 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1553 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1554 var elementType = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1555 $$typeof: REACT_MEMO_TYPE, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1556 type: type, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1557 compare: compare === undefined ? null : compare |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1558 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1559 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1560 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1561 var ownName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1562 Object.defineProperty(elementType, 'displayName', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1563 enumerable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1564 configurable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1565 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1566 return ownName; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1567 }, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1568 set: function (name) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1569 ownName = name; // The inner component shouldn't inherit this display name in most cases, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1570 // because the component may be used elsewhere. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1571 // But it's nice for anonymous functions to inherit the name, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1572 // so that our component-stack generation logic will display their frames. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1573 // An anonymous function generally suggests a pattern like: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1574 // React.memo((props) => {...}); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1575 // This kind of inner function is not used elsewhere so the side effect is okay. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1576 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1577 if (!type.name && !type.displayName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1578 type.displayName = name; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1579 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1580 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1581 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1582 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1583 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1584 return elementType; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1585 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1586 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1587 function resolveDispatcher() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1588 var dispatcher = ReactCurrentDispatcher.current; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1589 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1590 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1591 if (dispatcher === null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1592 error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1593 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1594 } // Will result in a null access error if accessed outside render phase. We |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1595 // intentionally don't throw our own error because this is in a hot path. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1596 // Also helps ensure this is inlined. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1597 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1598 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1599 return dispatcher; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1600 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1601 function useContext(Context) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1602 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1603 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1604 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1605 // TODO: add a more generic warning for invalid values. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1606 if (Context._context !== undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1607 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1608 // and nobody should be using this in existing code. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1609 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1610 if (realContext.Consumer === Context) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1611 error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1612 } else if (realContext.Provider === Context) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1613 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1614 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1615 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1616 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1617 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1618 return dispatcher.useContext(Context); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1619 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1620 function useState(initialState) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1621 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1622 return dispatcher.useState(initialState); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1623 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1624 function useReducer(reducer, initialArg, init) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1625 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1626 return dispatcher.useReducer(reducer, initialArg, init); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1627 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1628 function useRef(initialValue) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1629 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1630 return dispatcher.useRef(initialValue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1631 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1632 function useEffect(create, deps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1633 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1634 return dispatcher.useEffect(create, deps); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1635 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1636 function useInsertionEffect(create, deps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1637 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1638 return dispatcher.useInsertionEffect(create, deps); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1639 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1640 function useLayoutEffect(create, deps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1641 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1642 return dispatcher.useLayoutEffect(create, deps); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1643 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1644 function useCallback(callback, deps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1645 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1646 return dispatcher.useCallback(callback, deps); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1647 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1648 function useMemo(create, deps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1649 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1650 return dispatcher.useMemo(create, deps); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1651 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1652 function useImperativeHandle(ref, create, deps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1653 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1654 return dispatcher.useImperativeHandle(ref, create, deps); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1655 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1656 function useDebugValue(value, formatterFn) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1657 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1658 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1659 return dispatcher.useDebugValue(value, formatterFn); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1660 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1661 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1662 function useTransition() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1663 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1664 return dispatcher.useTransition(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1665 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1666 function useDeferredValue(value) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1667 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1668 return dispatcher.useDeferredValue(value); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1669 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1670 function useId() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1671 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1672 return dispatcher.useId(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1673 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1674 function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1675 var dispatcher = resolveDispatcher(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1676 return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1677 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1678 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1679 // Helpers to patch console.logs to avoid logging during side-effect free |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1680 // replaying on render function. This currently only patches the object |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1681 // lazily which won't cover if the log function was extracted eagerly. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1682 // We could also eagerly patch the method. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1683 var disabledDepth = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1684 var prevLog; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1685 var prevInfo; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1686 var prevWarn; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1687 var prevError; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1688 var prevGroup; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1689 var prevGroupCollapsed; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1690 var prevGroupEnd; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1691 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1692 function disabledLog() {} |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1693 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1694 disabledLog.__reactDisabledLog = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1695 function disableLogs() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1696 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1697 if (disabledDepth === 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1698 /* eslint-disable react-internal/no-production-logging */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1699 prevLog = console.log; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1700 prevInfo = console.info; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1701 prevWarn = console.warn; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1702 prevError = console.error; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1703 prevGroup = console.group; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1704 prevGroupCollapsed = console.groupCollapsed; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1705 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1706 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1707 var props = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1708 configurable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1709 enumerable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1710 value: disabledLog, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1711 writable: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1712 }; // $FlowFixMe Flow thinks console is immutable. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1713 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1714 Object.defineProperties(console, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1715 info: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1716 log: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1717 warn: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1718 error: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1719 group: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1720 groupCollapsed: props, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1721 groupEnd: props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1722 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1723 /* eslint-enable react-internal/no-production-logging */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1724 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1725 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1726 disabledDepth++; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1727 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1728 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1729 function reenableLogs() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1730 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1731 disabledDepth--; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1732 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1733 if (disabledDepth === 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1734 /* eslint-disable react-internal/no-production-logging */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1735 var props = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1736 configurable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1737 enumerable: true, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1738 writable: true |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1739 }; // $FlowFixMe Flow thinks console is immutable. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1740 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1741 Object.defineProperties(console, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1742 log: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1743 value: prevLog |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1744 }), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1745 info: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1746 value: prevInfo |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1747 }), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1748 warn: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1749 value: prevWarn |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1750 }), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1751 error: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1752 value: prevError |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1753 }), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1754 group: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1755 value: prevGroup |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1756 }), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1757 groupCollapsed: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1758 value: prevGroupCollapsed |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1759 }), |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1760 groupEnd: assign({}, props, { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1761 value: prevGroupEnd |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1762 }) |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1763 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1764 /* eslint-enable react-internal/no-production-logging */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1765 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1766 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1767 if (disabledDepth < 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1768 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1769 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1770 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1771 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1772 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1773 var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1774 var prefix; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1775 function describeBuiltInComponentFrame(name, source, ownerFn) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1776 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1777 if (prefix === undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1778 // Extract the VM specific prefix used by each line. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1779 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1780 throw Error(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1781 } catch (x) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1782 var match = x.stack.trim().match(/\n( *(at )?)/); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1783 prefix = match && match[1] || ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1784 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1785 } // We use the prefix to ensure our stacks line up with native stack frames. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1786 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1787 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1788 return '\n' + prefix + name; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1789 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1790 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1791 var reentry = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1792 var componentFrameCache; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1793 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1794 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1795 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1796 componentFrameCache = new PossiblyWeakMap(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1797 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1798 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1799 function describeNativeComponentFrame(fn, construct) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1800 // If something asked for a stack inside a fake render, it should get ignored. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1801 if ( !fn || reentry) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1802 return ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1803 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1804 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1805 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1806 var frame = componentFrameCache.get(fn); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1807 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1808 if (frame !== undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1809 return frame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1810 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1811 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1812 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1813 var control; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1814 reentry = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1815 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1816 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1817 Error.prepareStackTrace = undefined; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1818 var previousDispatcher; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1819 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1820 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1821 previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1822 // for warnings. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1823 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1824 ReactCurrentDispatcher$1.current = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1825 disableLogs(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1826 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1827 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1828 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1829 // This should throw. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1830 if (construct) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1831 // Something should be setting the props in the constructor. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1832 var Fake = function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1833 throw Error(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1834 }; // $FlowFixMe |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1835 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1836 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1837 Object.defineProperty(Fake.prototype, 'props', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1838 set: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1839 // We use a throwing setter instead of frozen or non-writable props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1840 // because that won't throw in a non-strict mode function. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1841 throw Error(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1842 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1843 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1844 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1845 if (typeof Reflect === 'object' && Reflect.construct) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1846 // We construct a different control for this case to include any extra |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1847 // frames added by the construct call. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1848 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1849 Reflect.construct(Fake, []); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1850 } catch (x) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1851 control = x; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1852 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1853 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1854 Reflect.construct(fn, [], Fake); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1855 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1856 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1857 Fake.call(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1858 } catch (x) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1859 control = x; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1860 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1861 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1862 fn.call(Fake.prototype); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1863 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1864 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1865 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1866 throw Error(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1867 } catch (x) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1868 control = x; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1869 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1870 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1871 fn(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1872 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1873 } catch (sample) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1874 // This is inlined manually because closure doesn't do it for us. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1875 if (sample && control && typeof sample.stack === 'string') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1876 // This extracts the first frame from the sample that isn't also in the control. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1877 // Skipping one frame that we assume is the frame that calls the two. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1878 var sampleLines = sample.stack.split('\n'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1879 var controlLines = control.stack.split('\n'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1880 var s = sampleLines.length - 1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1881 var c = controlLines.length - 1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1882 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1883 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1884 // We expect at least one stack frame to be shared. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1885 // Typically this will be the root most one. However, stack frames may be |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1886 // cut off due to maximum stack limits. In this case, one maybe cut off |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1887 // earlier than the other. We assume that the sample is longer or the same |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1888 // and there for cut off earlier. So we should find the root most frame in |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1889 // the sample somewhere in the control. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1890 c--; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1891 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1892 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1893 for (; s >= 1 && c >= 0; s--, c--) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1894 // Next we find the first one that isn't the same which should be the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1895 // frame that called our sample function and the control. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1896 if (sampleLines[s] !== controlLines[c]) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1897 // In V8, the first line is describing the message but other VMs don't. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1898 // If we're about to return the first line, and the control is also on the same |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1899 // line, that's a pretty good indicator that our sample threw at same line as |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1900 // the control. I.e. before we entered the sample frame. So we ignore this result. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1901 // This can happen if you passed a class to function component, or non-function. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1902 if (s !== 1 || c !== 1) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1903 do { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1904 s--; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1905 c--; // We may still have similar intermediate frames from the construct call. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1906 // The next one that isn't the same should be our match though. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1907 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1908 if (c < 0 || sampleLines[s] !== controlLines[c]) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1909 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1910 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>" |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1911 // but we have a user-provided "displayName" |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1912 // splice it in to make the stack more readable. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1913 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1914 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1915 if (fn.displayName && _frame.includes('<anonymous>')) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1916 _frame = _frame.replace('<anonymous>', fn.displayName); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1917 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1918 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1919 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1920 if (typeof fn === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1921 componentFrameCache.set(fn, _frame); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1922 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1923 } // Return the line we found. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1924 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1925 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1926 return _frame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1927 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1928 } while (s >= 1 && c >= 0); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1929 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1930 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1931 break; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1932 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1933 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1934 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1935 } finally { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1936 reentry = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1937 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1938 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1939 ReactCurrentDispatcher$1.current = previousDispatcher; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1940 reenableLogs(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1941 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1942 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1943 Error.prepareStackTrace = previousPrepareStackTrace; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1944 } // Fallback to just using the name if we couldn't make it throw. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1945 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1946 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1947 var name = fn ? fn.displayName || fn.name : ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1948 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1949 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1950 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1951 if (typeof fn === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1952 componentFrameCache.set(fn, syntheticFrame); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1953 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1954 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1955 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1956 return syntheticFrame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1957 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1958 function describeFunctionComponentFrame(fn, source, ownerFn) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1959 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1960 return describeNativeComponentFrame(fn, false); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1961 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1962 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1963 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1964 function shouldConstruct(Component) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1965 var prototype = Component.prototype; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1966 return !!(prototype && prototype.isReactComponent); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1967 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1968 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1969 function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1970 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1971 if (type == null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1972 return ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1973 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1974 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1975 if (typeof type === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1976 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1977 return describeNativeComponentFrame(type, shouldConstruct(type)); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1978 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1979 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1980 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1981 if (typeof type === 'string') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1982 return describeBuiltInComponentFrame(type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1983 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1984 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1985 switch (type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1986 case REACT_SUSPENSE_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1987 return describeBuiltInComponentFrame('Suspense'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1988 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1989 case REACT_SUSPENSE_LIST_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1990 return describeBuiltInComponentFrame('SuspenseList'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1991 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1992 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1993 if (typeof type === 'object') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1994 switch (type.$$typeof) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1995 case REACT_FORWARD_REF_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1996 return describeFunctionComponentFrame(type.render); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1997 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1998 case REACT_MEMO_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1999 // Memo may contain any component type so we recursively resolve it. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2000 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2001 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2002 case REACT_LAZY_TYPE: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2003 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2004 var lazyComponent = type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2005 var payload = lazyComponent._payload; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2006 var init = lazyComponent._init; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2007 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2008 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2009 // Lazy may contain any component type so we recursively resolve it. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2010 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2011 } catch (x) {} |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2012 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2013 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2014 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2015 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2016 return ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2017 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2018 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2019 var loggedTypeFailures = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2020 var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2021 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2022 function setCurrentlyValidatingElement(element) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2023 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2024 if (element) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2025 var owner = element._owner; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2026 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2027 ReactDebugCurrentFrame$1.setExtraStackFrame(stack); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2028 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2029 ReactDebugCurrentFrame$1.setExtraStackFrame(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2030 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2031 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2032 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2033 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2034 function checkPropTypes(typeSpecs, values, location, componentName, element) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2035 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2036 // $FlowFixMe This is okay but Flow doesn't know it. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2037 var has = Function.call.bind(hasOwnProperty); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2038 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2039 for (var typeSpecName in typeSpecs) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2040 if (has(typeSpecs, typeSpecName)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2041 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2042 // fail the render phase where it didn't fail before. So we log it. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2043 // After these have been cleaned up, we'll let them throw. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2044 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2045 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2046 // This is intentionally an invariant that gets caught. It's the same |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2047 // behavior as without this statement except with a better message. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2048 if (typeof typeSpecs[typeSpecName] !== 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2049 // eslint-disable-next-line react-internal/prod-error-codes |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2050 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2051 err.name = 'Invariant Violation'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2052 throw err; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2053 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2054 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2055 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2056 } catch (ex) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2057 error$1 = ex; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2058 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2059 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2060 if (error$1 && !(error$1 instanceof Error)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2061 setCurrentlyValidatingElement(element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2062 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2063 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2064 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2065 setCurrentlyValidatingElement(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2066 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2067 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2068 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2069 // Only monitor this failure once because there tends to be a lot of the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2070 // same error. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2071 loggedTypeFailures[error$1.message] = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2072 setCurrentlyValidatingElement(element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2073 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2074 error('Failed %s type: %s', location, error$1.message); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2075 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2076 setCurrentlyValidatingElement(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2077 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2078 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2079 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2080 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2081 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2082 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2083 function setCurrentlyValidatingElement$1(element) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2084 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2085 if (element) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2086 var owner = element._owner; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2087 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2088 setExtraStackFrame(stack); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2089 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2090 setExtraStackFrame(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2091 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2092 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2093 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2094 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2095 var propTypesMisspellWarningShown; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2096 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2097 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2098 propTypesMisspellWarningShown = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2099 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2100 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2101 function getDeclarationErrorAddendum() { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2102 if (ReactCurrentOwner.current) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2103 var name = getComponentNameFromType(ReactCurrentOwner.current.type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2104 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2105 if (name) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2106 return '\n\nCheck the render method of `' + name + '`.'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2107 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2108 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2109 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2110 return ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2111 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2112 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2113 function getSourceInfoErrorAddendum(source) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2114 if (source !== undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2115 var fileName = source.fileName.replace(/^.*[\\\/]/, ''); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2116 var lineNumber = source.lineNumber; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2117 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2118 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2119 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2120 return ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2121 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2122 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2123 function getSourceInfoErrorAddendumForProps(elementProps) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2124 if (elementProps !== null && elementProps !== undefined) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2125 return getSourceInfoErrorAddendum(elementProps.__source); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2126 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2127 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2128 return ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2129 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2130 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2131 * Warn if there's no key explicitly set on dynamic arrays of children or |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2132 * object keys are not valid. This allows us to keep track of children between |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2133 * updates. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2134 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2135 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2136 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2137 var ownerHasKeyUseWarning = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2138 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2139 function getCurrentComponentErrorInfo(parentType) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2140 var info = getDeclarationErrorAddendum(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2141 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2142 if (!info) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2143 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2144 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2145 if (parentName) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2146 info = "\n\nCheck the top-level render call using <" + parentName + ">."; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2147 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2148 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2149 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2150 return info; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2151 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2152 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2153 * Warn if the element doesn't have an explicit key assigned to it. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2154 * This element is in an array. The array could grow and shrink or be |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2155 * reordered. All children that haven't already been validated are required to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2156 * have a "key" property assigned to it. Error statuses are cached so a warning |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2157 * will only be shown once. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2158 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2159 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2160 * @param {ReactElement} element Element that requires a key. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2161 * @param {*} parentType element's parent's type. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2162 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2163 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2164 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2165 function validateExplicitKey(element, parentType) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2166 if (!element._store || element._store.validated || element.key != null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2167 return; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2168 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2169 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2170 element._store.validated = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2171 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2172 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2173 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2174 return; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2175 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2176 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2177 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2178 // property, it may be the creator of the child that's responsible for |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2179 // assigning it a key. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2180 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2181 var childOwner = ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2182 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2183 if (element && element._owner && element._owner !== ReactCurrentOwner.current) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2184 // Give the component that originally created this child. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2185 childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + "."; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2186 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2187 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2188 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2189 setCurrentlyValidatingElement$1(element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2190 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2191 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2192 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2193 setCurrentlyValidatingElement$1(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2194 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2195 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2196 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2197 * Ensure that every element either is passed in a static location, in an |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2198 * array with an explicit keys property defined, or in an object literal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2199 * with valid key property. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2200 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2201 * @internal |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2202 * @param {ReactNode} node Statically passed child of any type. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2203 * @param {*} parentType node's parent's type. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2204 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2205 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2206 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2207 function validateChildKeys(node, parentType) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2208 if (typeof node !== 'object') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2209 return; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2210 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2211 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2212 if (isArray(node)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2213 for (var i = 0; i < node.length; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2214 var child = node[i]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2215 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2216 if (isValidElement(child)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2217 validateExplicitKey(child, parentType); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2218 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2219 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2220 } else if (isValidElement(node)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2221 // This element was passed in a valid location. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2222 if (node._store) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2223 node._store.validated = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2224 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2225 } else if (node) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2226 var iteratorFn = getIteratorFn(node); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2227 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2228 if (typeof iteratorFn === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2229 // Entry iterators used to provide implicit keys, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2230 // but now we print a separate warning for them later. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2231 if (iteratorFn !== node.entries) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2232 var iterator = iteratorFn.call(node); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2233 var step; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2234 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2235 while (!(step = iterator.next()).done) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2236 if (isValidElement(step.value)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2237 validateExplicitKey(step.value, parentType); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2238 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2239 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2240 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2241 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2242 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2243 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2244 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2245 * Given an element, validate that its props follow the propTypes definition, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2246 * provided by the type. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2247 * |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2248 * @param {ReactElement} element |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2249 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2250 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2251 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2252 function validatePropTypes(element) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2253 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2254 var type = element.type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2255 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2256 if (type === null || type === undefined || typeof type === 'string') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2257 return; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2258 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2259 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2260 var propTypes; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2261 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2262 if (typeof type === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2263 propTypes = type.propTypes; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2264 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2265 // Inner props are checked in the reconciler. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2266 type.$$typeof === REACT_MEMO_TYPE)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2267 propTypes = type.propTypes; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2268 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2269 return; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2270 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2271 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2272 if (propTypes) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2273 // Intentionally inside to avoid triggering lazy initializers: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2274 var name = getComponentNameFromType(type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2275 checkPropTypes(propTypes, element.props, 'prop', name, element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2276 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2277 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2278 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2279 var _name = getComponentNameFromType(type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2280 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2281 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2282 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2283 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2284 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2285 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2286 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2287 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2288 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2289 /** |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2290 * Given a fragment, validate that it can only be provided with fragment props |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2291 * @param {ReactElement} fragment |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2292 */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2293 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2294 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2295 function validateFragmentProps(fragment) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2296 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2297 var keys = Object.keys(fragment.props); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2298 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2299 for (var i = 0; i < keys.length; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2300 var key = keys[i]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2301 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2302 if (key !== 'children' && key !== 'key') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2303 setCurrentlyValidatingElement$1(fragment); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2304 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2305 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2306 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2307 setCurrentlyValidatingElement$1(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2308 break; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2309 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2310 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2311 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2312 if (fragment.ref !== null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2313 setCurrentlyValidatingElement$1(fragment); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2314 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2315 error('Invalid attribute `ref` supplied to `React.Fragment`.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2316 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2317 setCurrentlyValidatingElement$1(null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2318 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2319 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2320 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2321 function createElementWithValidation(type, props, children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2322 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2323 // succeed and there will likely be errors in render. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2324 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2325 if (!validType) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2326 var info = ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2327 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2328 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2329 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2330 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2331 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2332 var sourceInfo = getSourceInfoErrorAddendumForProps(props); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2333 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2334 if (sourceInfo) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2335 info += sourceInfo; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2336 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2337 info += getDeclarationErrorAddendum(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2338 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2339 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2340 var typeString; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2341 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2342 if (type === null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2343 typeString = 'null'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2344 } else if (isArray(type)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2345 typeString = 'array'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2346 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2347 typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />"; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2348 info = ' Did you accidentally export a JSX literal instead of a component?'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2349 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2350 typeString = typeof type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2351 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2352 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2353 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2354 error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2355 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2356 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2357 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2358 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2359 // TODO: Drop this when these are no longer allowed as the type argument. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2360 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2361 if (element == null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2362 return element; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2363 } // Skip key warning if the type isn't valid since our key validation logic |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2364 // doesn't expect a non-string/function type and can throw confusing errors. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2365 // We don't want exception behavior to differ between dev and prod. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2366 // (Rendering will throw with a helpful message and as soon as the type is |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2367 // fixed, the key warnings will appear.) |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2368 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2369 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2370 if (validType) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2371 for (var i = 2; i < arguments.length; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2372 validateChildKeys(arguments[i], type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2373 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2374 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2375 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2376 if (type === REACT_FRAGMENT_TYPE) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2377 validateFragmentProps(element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2378 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2379 validatePropTypes(element); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2380 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2381 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2382 return element; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2383 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2384 var didWarnAboutDeprecatedCreateFactory = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2385 function createFactoryWithValidation(type) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2386 var validatedFactory = createElementWithValidation.bind(null, type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2387 validatedFactory.type = type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2388 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2389 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2390 if (!didWarnAboutDeprecatedCreateFactory) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2391 didWarnAboutDeprecatedCreateFactory = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2392 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2393 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2394 } // Legacy hook: remove it |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2395 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2396 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2397 Object.defineProperty(validatedFactory, 'type', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2398 enumerable: false, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2399 get: function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2400 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2401 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2402 Object.defineProperty(this, 'type', { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2403 value: type |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2404 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2405 return type; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2406 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2407 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2408 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2409 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2410 return validatedFactory; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2411 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2412 function cloneElementWithValidation(element, props, children) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2413 var newElement = cloneElement.apply(this, arguments); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2414 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2415 for (var i = 2; i < arguments.length; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2416 validateChildKeys(arguments[i], newElement.type); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2417 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2418 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2419 validatePropTypes(newElement); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2420 return newElement; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2421 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2422 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2423 function startTransition(scope, options) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2424 var prevTransition = ReactCurrentBatchConfig.transition; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2425 ReactCurrentBatchConfig.transition = {}; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2426 var currentTransition = ReactCurrentBatchConfig.transition; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2427 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2428 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2429 ReactCurrentBatchConfig.transition._updatedFibers = new Set(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2430 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2431 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2432 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2433 scope(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2434 } finally { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2435 ReactCurrentBatchConfig.transition = prevTransition; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2436 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2437 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2438 if (prevTransition === null && currentTransition._updatedFibers) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2439 var updatedFibersCount = currentTransition._updatedFibers.size; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2440 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2441 if (updatedFibersCount > 10) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2442 warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2443 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2444 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2445 currentTransition._updatedFibers.clear(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2446 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2447 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2448 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2449 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2450 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2451 var didWarnAboutMessageChannel = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2452 var enqueueTaskImpl = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2453 function enqueueTask(task) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2454 if (enqueueTaskImpl === null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2455 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2456 // read require off the module object to get around the bundlers. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2457 // we don't want them to detect a require and bundle a Node polyfill. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2458 var requireString = ('require' + Math.random()).slice(0, 7); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2459 var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2460 // version of setImmediate, bypassing fake timers if any. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2461 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2462 enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2463 } catch (_err) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2464 // we're in a browser |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2465 // we can't use regular timers because they may still be faked |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2466 // so we try MessageChannel+postMessage instead |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2467 enqueueTaskImpl = function (callback) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2468 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2469 if (didWarnAboutMessageChannel === false) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2470 didWarnAboutMessageChannel = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2471 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2472 if (typeof MessageChannel === 'undefined') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2473 error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2474 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2475 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2476 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2477 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2478 var channel = new MessageChannel(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2479 channel.port1.onmessage = callback; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2480 channel.port2.postMessage(undefined); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2481 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2482 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2483 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2484 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2485 return enqueueTaskImpl(task); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2486 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2487 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2488 var actScopeDepth = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2489 var didWarnNoAwaitAct = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2490 function act(callback) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2491 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2492 // `act` calls can be nested, so we track the depth. This represents the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2493 // number of `act` scopes on the stack. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2494 var prevActScopeDepth = actScopeDepth; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2495 actScopeDepth++; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2496 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2497 if (ReactCurrentActQueue.current === null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2498 // This is the outermost `act` scope. Initialize the queue. The reconciler |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2499 // will detect the queue and use it instead of Scheduler. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2500 ReactCurrentActQueue.current = []; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2501 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2502 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2503 var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2504 var result; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2505 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2506 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2507 // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2508 // set to `true` while the given callback is executed, not for updates |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2509 // triggered during an async event, because this is how the legacy |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2510 // implementation of `act` behaved. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2511 ReactCurrentActQueue.isBatchingLegacy = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2512 result = callback(); // Replicate behavior of original `act` implementation in legacy mode, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2513 // which flushed updates immediately after the scope function exits, even |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2514 // if it's an async function. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2515 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2516 if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2517 var queue = ReactCurrentActQueue.current; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2518 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2519 if (queue !== null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2520 ReactCurrentActQueue.didScheduleLegacyUpdate = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2521 flushActQueue(queue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2522 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2523 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2524 } catch (error) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2525 popActScope(prevActScopeDepth); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2526 throw error; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2527 } finally { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2528 ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2529 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2530 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2531 if (result !== null && typeof result === 'object' && typeof result.then === 'function') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2532 var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2533 // for it to resolve before exiting the current scope. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2534 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2535 var wasAwaited = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2536 var thenable = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2537 then: function (resolve, reject) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2538 wasAwaited = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2539 thenableResult.then(function (returnValue) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2540 popActScope(prevActScopeDepth); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2541 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2542 if (actScopeDepth === 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2543 // We've exited the outermost act scope. Recursively flush the |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2544 // queue until there's no remaining work. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2545 recursivelyFlushAsyncActWork(returnValue, resolve, reject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2546 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2547 resolve(returnValue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2548 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2549 }, function (error) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2550 // The callback threw an error. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2551 popActScope(prevActScopeDepth); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2552 reject(error); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2553 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2554 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2555 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2556 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2557 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2558 if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2559 // eslint-disable-next-line no-undef |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2560 Promise.resolve().then(function () {}).then(function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2561 if (!wasAwaited) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2562 didWarnNoAwaitAct = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2563 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2564 error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2565 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2566 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2567 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2568 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2569 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2570 return thenable; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2571 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2572 var returnValue = result; // The callback is not an async function. Exit the current scope |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2573 // immediately, without awaiting. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2574 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2575 popActScope(prevActScopeDepth); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2576 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2577 if (actScopeDepth === 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2578 // Exiting the outermost act scope. Flush the queue. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2579 var _queue = ReactCurrentActQueue.current; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2580 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2581 if (_queue !== null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2582 flushActQueue(_queue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2583 ReactCurrentActQueue.current = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2584 } // Return a thenable. If the user awaits it, we'll flush again in |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2585 // case additional work was scheduled by a microtask. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2586 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2587 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2588 var _thenable = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2589 then: function (resolve, reject) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2590 // Confirm we haven't re-entered another `act` scope, in case |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2591 // the user does something weird like await the thenable |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2592 // multiple times. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2593 if (ReactCurrentActQueue.current === null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2594 // Recursively flush the queue until there's no remaining work. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2595 ReactCurrentActQueue.current = []; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2596 recursivelyFlushAsyncActWork(returnValue, resolve, reject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2597 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2598 resolve(returnValue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2599 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2600 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2601 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2602 return _thenable; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2603 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2604 // Since we're inside a nested `act` scope, the returned thenable |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2605 // immediately resolves. The outer scope will flush the queue. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2606 var _thenable2 = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2607 then: function (resolve, reject) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2608 resolve(returnValue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2609 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2610 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2611 return _thenable2; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2612 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2613 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2614 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2615 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2616 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2617 function popActScope(prevActScopeDepth) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2618 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2619 if (prevActScopeDepth !== actScopeDepth - 1) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2620 error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. '); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2621 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2622 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2623 actScopeDepth = prevActScopeDepth; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2624 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2625 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2626 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2627 function recursivelyFlushAsyncActWork(returnValue, resolve, reject) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2628 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2629 var queue = ReactCurrentActQueue.current; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2630 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2631 if (queue !== null) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2632 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2633 flushActQueue(queue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2634 enqueueTask(function () { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2635 if (queue.length === 0) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2636 // No additional work was scheduled. Finish. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2637 ReactCurrentActQueue.current = null; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2638 resolve(returnValue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2639 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2640 // Keep flushing work until there's none left. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2641 recursivelyFlushAsyncActWork(returnValue, resolve, reject); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2642 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2643 }); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2644 } catch (error) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2645 reject(error); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2646 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2647 } else { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2648 resolve(returnValue); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2649 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2650 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2651 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2652 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2653 var isFlushing = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2654 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2655 function flushActQueue(queue) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2656 { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2657 if (!isFlushing) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2658 // Prevent re-entrance. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2659 isFlushing = true; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2660 var i = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2661 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2662 try { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2663 for (; i < queue.length; i++) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2664 var callback = queue[i]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2665 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2666 do { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2667 callback = callback(true); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2668 } while (callback !== null); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2669 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2670 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2671 queue.length = 0; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2672 } catch (error) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2673 // If something throws, leave the remaining callbacks on the queue. |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2674 queue = queue.slice(i + 1); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2675 throw error; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2676 } finally { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2677 isFlushing = false; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2678 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2679 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2680 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2681 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2682 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2683 var createElement$1 = createElementWithValidation ; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2684 var cloneElement$1 = cloneElementWithValidation ; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2685 var createFactory = createFactoryWithValidation ; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2686 var Children = { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2687 map: mapChildren, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2688 forEach: forEachChildren, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2689 count: countChildren, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2690 toArray: toArray, |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2691 only: onlyChild |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2692 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2693 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2694 exports.Children = Children; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2695 exports.Component = Component; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2696 exports.Fragment = REACT_FRAGMENT_TYPE; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2697 exports.Profiler = REACT_PROFILER_TYPE; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2698 exports.PureComponent = PureComponent; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2699 exports.StrictMode = REACT_STRICT_MODE_TYPE; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2700 exports.Suspense = REACT_SUSPENSE_TYPE; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2701 exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2702 exports.act = act; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2703 exports.cloneElement = cloneElement$1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2704 exports.createContext = createContext; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2705 exports.createElement = createElement$1; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2706 exports.createFactory = createFactory; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2707 exports.createRef = createRef; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2708 exports.forwardRef = forwardRef; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2709 exports.isValidElement = isValidElement; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2710 exports.lazy = lazy; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2711 exports.memo = memo; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2712 exports.startTransition = startTransition; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2713 exports.unstable_act = act; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2714 exports.useCallback = useCallback; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2715 exports.useContext = useContext; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2716 exports.useDebugValue = useDebugValue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2717 exports.useDeferredValue = useDeferredValue; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2718 exports.useEffect = useEffect; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2719 exports.useId = useId; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2720 exports.useImperativeHandle = useImperativeHandle; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2721 exports.useInsertionEffect = useInsertionEffect; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2722 exports.useLayoutEffect = useLayoutEffect; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2723 exports.useMemo = useMemo; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2724 exports.useReducer = useReducer; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2725 exports.useRef = useRef; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2726 exports.useState = useState; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2727 exports.useSyncExternalStore = useSyncExternalStore; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2728 exports.useTransition = useTransition; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2729 exports.version = ReactVersion; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2730 /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2731 if ( |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2732 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2733 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2734 'function' |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2735 ) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2736 __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2737 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2738 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2739 })(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2740 } |