react 0.0.0-f9e41e3a5 → 0.0.0-f42431abe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +5 -5
- package/cjs/react.development.js +967 -582
- package/cjs/react.production.min.js +17 -17
- package/package.json +2 -3
- package/umd/react.development.js +2883 -2275
- package/umd/react.production.min.js +25 -26
- package/umd/react.profiling.min.js +33 -30
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"branch": "
|
|
3
|
-
"buildNumber": "
|
|
4
|
-
"checksum": "
|
|
5
|
-
"commit": "
|
|
2
|
+
"branch": "master",
|
|
3
|
+
"buildNumber": "68677",
|
|
4
|
+
"checksum": "79816fa",
|
|
5
|
+
"commit": "f42431abe",
|
|
6
6
|
"environment": "ci",
|
|
7
|
-
"reactVersion": "16.
|
|
7
|
+
"reactVersion": "16.12.0-f42431abe"
|
|
8
8
|
}
|
package/cjs/react.development.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.0.0-
|
|
1
|
+
/** @license React v0.0.0-f42431abe
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -20,173 +20,300 @@ var checkPropTypes = require('prop-types/checkPropTypes');
|
|
|
20
20
|
|
|
21
21
|
// TODO: this is special because it gets imported during build.
|
|
22
22
|
|
|
23
|
-
var ReactVersion = '16.
|
|
23
|
+
var ReactVersion = '16.12.0-f42431abe';
|
|
24
24
|
|
|
25
25
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
26
26
|
// nor polyfill, then a plain number is used for performance.
|
|
27
27
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
28
|
-
|
|
29
28
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
30
29
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
31
30
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
32
31
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
33
32
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
34
33
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
35
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
34
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
35
|
+
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
36
|
+
|
|
36
37
|
|
|
37
38
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
38
39
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
39
40
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
41
|
+
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
40
42
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
41
43
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
42
|
-
|
|
44
|
+
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
45
|
+
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
46
|
+
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
43
47
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
44
48
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
45
|
-
|
|
46
49
|
function getIteratorFn(maybeIterable) {
|
|
47
50
|
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
48
51
|
return null;
|
|
49
52
|
}
|
|
53
|
+
|
|
50
54
|
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
55
|
+
|
|
51
56
|
if (typeof maybeIterator === 'function') {
|
|
52
57
|
return maybeIterator;
|
|
53
58
|
}
|
|
59
|
+
|
|
54
60
|
return null;
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
/**
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
* Keeps track of the current dispatcher.
|
|
65
|
+
*/
|
|
66
|
+
var ReactCurrentDispatcher = {
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* @type {ReactComponent}
|
|
70
|
+
*/
|
|
71
|
+
current: null
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Keeps track of the current batch's configuration such as how long an update
|
|
76
|
+
* should suspend for if it needs to.
|
|
77
|
+
*/
|
|
78
|
+
var ReactCurrentBatchConfig = {
|
|
79
|
+
suspense: null
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Keeps track of the current owner.
|
|
63
84
|
*
|
|
64
|
-
* The
|
|
65
|
-
*
|
|
85
|
+
* The current owner is the component who should own any components that are
|
|
86
|
+
* currently being constructed.
|
|
66
87
|
*/
|
|
88
|
+
var ReactCurrentOwner = {
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
* @type {ReactComponent}
|
|
92
|
+
*/
|
|
93
|
+
current: null
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
97
|
+
var describeComponentFrame = function (name, source, ownerName) {
|
|
98
|
+
var sourceInfo = '';
|
|
67
99
|
|
|
68
|
-
|
|
100
|
+
if (source) {
|
|
101
|
+
var path = source.fileName;
|
|
102
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
69
103
|
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
104
|
+
{
|
|
105
|
+
// In DEV, include code for a common special case:
|
|
106
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
107
|
+
if (/^index\./.test(fileName)) {
|
|
108
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
109
|
+
|
|
110
|
+
if (match) {
|
|
111
|
+
var pathBeforeSlash = match[1];
|
|
112
|
+
|
|
113
|
+
if (pathBeforeSlash) {
|
|
114
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
115
|
+
fileName = folderName + '/' + fileName;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
74
119
|
}
|
|
75
|
-
|
|
120
|
+
|
|
121
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
122
|
+
} else if (ownerName) {
|
|
123
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
var Resolved = 1;
|
|
130
|
+
|
|
131
|
+
function refineResolvedLazyComponent(lazyComponent) {
|
|
132
|
+
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
136
|
+
var functionName = innerType.displayName || innerType.name || '';
|
|
137
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
76
138
|
}
|
|
77
139
|
|
|
78
|
-
function
|
|
79
|
-
|
|
140
|
+
function getComponentName(type) {
|
|
141
|
+
if (type == null) {
|
|
142
|
+
// Host root, text node or just invalid type.
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
80
145
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
85
|
-
} else {
|
|
86
|
-
var args = [a, b, c, d, e, f];
|
|
87
|
-
var argIndex = 0;
|
|
88
|
-
error = new Error(format.replace(/%s/g, function () {
|
|
89
|
-
return args[argIndex++];
|
|
90
|
-
}));
|
|
91
|
-
error.name = 'Invariant Violation';
|
|
146
|
+
{
|
|
147
|
+
if (typeof type.tag === 'number') {
|
|
148
|
+
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
92
149
|
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (typeof type === 'function') {
|
|
153
|
+
return type.displayName || type.name || null;
|
|
154
|
+
}
|
|
93
155
|
|
|
94
|
-
|
|
95
|
-
|
|
156
|
+
if (typeof type === 'string') {
|
|
157
|
+
return type;
|
|
96
158
|
}
|
|
97
|
-
}
|
|
98
159
|
|
|
99
|
-
|
|
100
|
-
|
|
160
|
+
switch (type) {
|
|
161
|
+
case REACT_FRAGMENT_TYPE:
|
|
162
|
+
return 'Fragment';
|
|
101
163
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
|
105
|
-
*
|
|
106
|
-
* Only change is we use console.warn instead of console.error,
|
|
107
|
-
* and do nothing when 'console' is not supported.
|
|
108
|
-
* This really simplifies the code.
|
|
109
|
-
* ---
|
|
110
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
111
|
-
* This can be used to log issues in development environments in critical
|
|
112
|
-
* paths. Removing the logging code for production environments will keep the
|
|
113
|
-
* same logic and follow the same code paths.
|
|
114
|
-
*/
|
|
164
|
+
case REACT_PORTAL_TYPE:
|
|
165
|
+
return 'Portal';
|
|
115
166
|
|
|
116
|
-
|
|
167
|
+
case REACT_PROFILER_TYPE:
|
|
168
|
+
return "Profiler";
|
|
117
169
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
121
|
-
args[_key - 1] = arguments[_key];
|
|
122
|
-
}
|
|
170
|
+
case REACT_STRICT_MODE_TYPE:
|
|
171
|
+
return 'StrictMode';
|
|
123
172
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return args[argIndex++];
|
|
127
|
-
});
|
|
128
|
-
if (typeof console !== 'undefined') {
|
|
129
|
-
console.warn(message);
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
// --- Welcome to debugging React ---
|
|
133
|
-
// This error was thrown as a convenience so that you can use this stack
|
|
134
|
-
// to find the callsite that caused this warning to fire.
|
|
135
|
-
throw new Error(message);
|
|
136
|
-
} catch (x) {}
|
|
137
|
-
};
|
|
173
|
+
case REACT_SUSPENSE_TYPE:
|
|
174
|
+
return 'Suspense';
|
|
138
175
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
176
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
177
|
+
return 'SuspenseList';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (typeof type === 'object') {
|
|
181
|
+
switch (type.$$typeof) {
|
|
182
|
+
case REACT_CONTEXT_TYPE:
|
|
183
|
+
return 'Context.Consumer';
|
|
184
|
+
|
|
185
|
+
case REACT_PROVIDER_TYPE:
|
|
186
|
+
return 'Context.Provider';
|
|
187
|
+
|
|
188
|
+
case REACT_FORWARD_REF_TYPE:
|
|
189
|
+
return getWrappedName(type, type.render, 'ForwardRef');
|
|
190
|
+
|
|
191
|
+
case REACT_MEMO_TYPE:
|
|
192
|
+
return getComponentName(type.type);
|
|
193
|
+
|
|
194
|
+
case REACT_LAZY_TYPE:
|
|
195
|
+
{
|
|
196
|
+
var thenable = type;
|
|
197
|
+
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
198
|
+
|
|
199
|
+
if (resolvedThenable) {
|
|
200
|
+
return getComponentName(resolvedThenable);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
142
205
|
}
|
|
143
|
-
|
|
144
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
145
|
-
args[_key2 - 2] = arguments[_key2];
|
|
146
|
-
}
|
|
206
|
+
}
|
|
147
207
|
|
|
148
|
-
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var ReactDebugCurrentFrame = {};
|
|
212
|
+
var currentlyValidatingElement = null;
|
|
213
|
+
function setCurrentlyValidatingElement(element) {
|
|
214
|
+
{
|
|
215
|
+
currentlyValidatingElement = element;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
{
|
|
220
|
+
// Stack implementation injected by the current renderer.
|
|
221
|
+
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
222
|
+
|
|
223
|
+
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
224
|
+
var stack = ''; // Add an extra top frame while an element is being validated
|
|
225
|
+
|
|
226
|
+
if (currentlyValidatingElement) {
|
|
227
|
+
var name = getComponentName(currentlyValidatingElement.type);
|
|
228
|
+
var owner = currentlyValidatingElement._owner;
|
|
229
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
230
|
+
} // Delegate to the injected renderer-specific implementation
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
234
|
+
|
|
235
|
+
if (impl) {
|
|
236
|
+
stack += impl() || '';
|
|
149
237
|
}
|
|
238
|
+
|
|
239
|
+
return stack;
|
|
150
240
|
};
|
|
151
241
|
}
|
|
152
242
|
|
|
153
|
-
var lowPriorityWarning$1 = lowPriorityWarning;
|
|
154
|
-
|
|
155
243
|
/**
|
|
156
|
-
*
|
|
157
|
-
* This can be used to log issues in development environments in critical
|
|
158
|
-
* paths. Removing the logging code for production environments will keep the
|
|
159
|
-
* same logic and follow the same code paths.
|
|
244
|
+
* Used by act() to track whether you're inside an act() scope.
|
|
160
245
|
*/
|
|
246
|
+
var IsSomeRendererActing = {
|
|
247
|
+
current: false
|
|
248
|
+
};
|
|
161
249
|
|
|
162
|
-
var
|
|
250
|
+
var ReactSharedInternals = {
|
|
251
|
+
ReactCurrentDispatcher: ReactCurrentDispatcher,
|
|
252
|
+
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
|
|
253
|
+
ReactCurrentOwner: ReactCurrentOwner,
|
|
254
|
+
IsSomeRendererActing: IsSomeRendererActing,
|
|
255
|
+
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
256
|
+
assign: _assign
|
|
257
|
+
};
|
|
163
258
|
|
|
164
259
|
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
260
|
+
_assign(ReactSharedInternals, {
|
|
261
|
+
// These should not be included in production.
|
|
262
|
+
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
|
263
|
+
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
|
264
|
+
// TODO: remove in React 17.0.
|
|
265
|
+
ReactComponentTreeHook: {}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
169
268
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
269
|
+
// by calls to these methods by a Babel plugin.
|
|
270
|
+
//
|
|
271
|
+
// In PROD (or in packages without access to React internals),
|
|
272
|
+
// they are left as they are instead.
|
|
273
|
+
|
|
274
|
+
function warn(format) {
|
|
275
|
+
{
|
|
276
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
277
|
+
args[_key - 1] = arguments[_key];
|
|
176
278
|
}
|
|
177
|
-
|
|
178
|
-
|
|
279
|
+
|
|
280
|
+
printWarning('warn', format, args);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function error(format) {
|
|
284
|
+
{
|
|
285
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
286
|
+
args[_key2 - 1] = arguments[_key2];
|
|
179
287
|
}
|
|
180
|
-
if (typeof console !== 'undefined') {
|
|
181
|
-
var argsWithFormat = args.map(function (item) {
|
|
182
|
-
return '' + item;
|
|
183
|
-
});
|
|
184
|
-
argsWithFormat.unshift('Warning: ' + format);
|
|
185
288
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
289
|
+
printWarning('error', format, args);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function printWarning(level, format, args) {
|
|
294
|
+
{
|
|
295
|
+
var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
|
|
296
|
+
|
|
297
|
+
if (!hasExistingStack) {
|
|
298
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
299
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
300
|
+
|
|
301
|
+
if (stack !== '') {
|
|
302
|
+
format += '%s';
|
|
303
|
+
args = args.concat([stack]);
|
|
304
|
+
}
|
|
189
305
|
}
|
|
306
|
+
|
|
307
|
+
var argsWithFormat = args.map(function (item) {
|
|
308
|
+
return '' + item;
|
|
309
|
+
}); // Careful: RN currently depends on this prefix
|
|
310
|
+
|
|
311
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
312
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
313
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
314
|
+
|
|
315
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
316
|
+
|
|
190
317
|
try {
|
|
191
318
|
// --- Welcome to debugging React ---
|
|
192
319
|
// This error was thrown as a convenience so that you can use this stack
|
|
@@ -197,10 +324,23 @@ var warningWithoutStack = function () {};
|
|
|
197
324
|
});
|
|
198
325
|
throw new Error(message);
|
|
199
326
|
} catch (x) {}
|
|
200
|
-
}
|
|
327
|
+
}
|
|
201
328
|
}
|
|
202
329
|
|
|
203
|
-
|
|
330
|
+
// Do not require this module directly! Use normal `invariant` calls with
|
|
331
|
+
// template literal strings. The messages will be replaced with error codes
|
|
332
|
+
// during build.
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
336
|
+
*
|
|
337
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
338
|
+
* to provide information about what broke and what you were
|
|
339
|
+
* expecting.
|
|
340
|
+
*
|
|
341
|
+
* The invariant message will be stripped in production, but the invariant
|
|
342
|
+
* will remain to ensure logic does not differ in production.
|
|
343
|
+
*/
|
|
204
344
|
|
|
205
345
|
var didWarnStateUpdateForUnmountedComponent = {};
|
|
206
346
|
|
|
@@ -208,18 +348,22 @@ function warnNoop(publicInstance, callerName) {
|
|
|
208
348
|
{
|
|
209
349
|
var _constructor = publicInstance.constructor;
|
|
210
350
|
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
|
211
|
-
var warningKey = componentName +
|
|
351
|
+
var warningKey = componentName + "." + callerName;
|
|
352
|
+
|
|
212
353
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
213
354
|
return;
|
|
214
355
|
}
|
|
215
|
-
|
|
356
|
+
|
|
357
|
+
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);
|
|
358
|
+
|
|
216
359
|
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
|
217
360
|
}
|
|
218
361
|
}
|
|
219
|
-
|
|
220
362
|
/**
|
|
221
363
|
* This is the abstract API for an update queue.
|
|
222
364
|
*/
|
|
365
|
+
|
|
366
|
+
|
|
223
367
|
var ReactNoopUpdateQueue = {
|
|
224
368
|
/**
|
|
225
369
|
* Checks whether or not this composite component is mounted.
|
|
@@ -286,25 +430,26 @@ var ReactNoopUpdateQueue = {
|
|
|
286
430
|
};
|
|
287
431
|
|
|
288
432
|
var emptyObject = {};
|
|
433
|
+
|
|
289
434
|
{
|
|
290
435
|
Object.freeze(emptyObject);
|
|
291
436
|
}
|
|
292
|
-
|
|
293
437
|
/**
|
|
294
438
|
* Base class helpers for the updating state of a component.
|
|
295
439
|
*/
|
|
440
|
+
|
|
441
|
+
|
|
296
442
|
function Component(props, context, updater) {
|
|
297
443
|
this.props = props;
|
|
298
|
-
this.context = context;
|
|
299
|
-
|
|
300
|
-
this.refs = emptyObject;
|
|
301
|
-
// We initialize the default updater but the real one gets injected by the
|
|
444
|
+
this.context = context; // If a component has string refs, we will assign a different object later.
|
|
445
|
+
|
|
446
|
+
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
|
|
302
447
|
// renderer.
|
|
448
|
+
|
|
303
449
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
304
450
|
}
|
|
305
451
|
|
|
306
452
|
Component.prototype.isReactComponent = {};
|
|
307
|
-
|
|
308
453
|
/**
|
|
309
454
|
* Sets a subset of the state. Always use this to mutate
|
|
310
455
|
* state. You should treat `this.state` as immutable.
|
|
@@ -330,11 +475,16 @@ Component.prototype.isReactComponent = {};
|
|
|
330
475
|
* @final
|
|
331
476
|
* @protected
|
|
332
477
|
*/
|
|
478
|
+
|
|
333
479
|
Component.prototype.setState = function (partialState, callback) {
|
|
334
|
-
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)
|
|
480
|
+
if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
|
|
481
|
+
{
|
|
482
|
+
throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
335
486
|
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
|
336
487
|
};
|
|
337
|
-
|
|
338
488
|
/**
|
|
339
489
|
* Forces an update. This should only be invoked when it is known with
|
|
340
490
|
* certainty that we are **not** in a DOM transaction.
|
|
@@ -349,284 +499,97 @@ Component.prototype.setState = function (partialState, callback) {
|
|
|
349
499
|
* @final
|
|
350
500
|
* @protected
|
|
351
501
|
*/
|
|
352
|
-
Component.prototype.forceUpdate = function (callback) {
|
|
353
|
-
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
|
354
|
-
};
|
|
355
502
|
|
|
356
|
-
/**
|
|
357
|
-
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
|
358
|
-
* we would like to deprecate them, we're not going to move them over to this
|
|
359
|
-
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
360
|
-
*/
|
|
361
|
-
{
|
|
362
|
-
var deprecatedAPIs = {
|
|
363
|
-
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
364
|
-
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
365
|
-
};
|
|
366
|
-
var defineDeprecationWarning = function (methodName, info) {
|
|
367
|
-
Object.defineProperty(Component.prototype, methodName, {
|
|
368
|
-
get: function () {
|
|
369
|
-
lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
|
370
|
-
return undefined;
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
};
|
|
374
|
-
for (var fnName in deprecatedAPIs) {
|
|
375
|
-
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
376
|
-
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
function ComponentDummy() {}
|
|
382
|
-
ComponentDummy.prototype = Component.prototype;
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Convenience component with default shallow equality check for sCU.
|
|
386
|
-
*/
|
|
387
|
-
function PureComponent(props, context, updater) {
|
|
388
|
-
this.props = props;
|
|
389
|
-
this.context = context;
|
|
390
|
-
// If a component has string refs, we will assign a different object later.
|
|
391
|
-
this.refs = emptyObject;
|
|
392
|
-
this.updater = updater || ReactNoopUpdateQueue;
|
|
393
|
-
}
|
|
394
503
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
// Avoid an extra prototype jump for these methods.
|
|
398
|
-
_assign(pureComponentPrototype, Component.prototype);
|
|
399
|
-
pureComponentPrototype.isPureReactComponent = true;
|
|
400
|
-
|
|
401
|
-
// an immutable object with a single mutable value
|
|
402
|
-
function createRef() {
|
|
403
|
-
var refObject = {
|
|
404
|
-
current: null
|
|
405
|
-
};
|
|
406
|
-
{
|
|
407
|
-
Object.seal(refObject);
|
|
408
|
-
}
|
|
409
|
-
return refObject;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Keeps track of the current dispatcher.
|
|
414
|
-
*/
|
|
415
|
-
var ReactCurrentDispatcher = {
|
|
416
|
-
/**
|
|
417
|
-
* @internal
|
|
418
|
-
* @type {ReactComponent}
|
|
419
|
-
*/
|
|
420
|
-
current: null
|
|
504
|
+
Component.prototype.forceUpdate = function (callback) {
|
|
505
|
+
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
|
421
506
|
};
|
|
422
|
-
|
|
423
507
|
/**
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
|
|
428
|
-
*/
|
|
429
|
-
var ReactCurrentOwner = {
|
|
430
|
-
/**
|
|
431
|
-
* @internal
|
|
432
|
-
* @type {ReactComponent}
|
|
433
|
-
*/
|
|
434
|
-
current: null
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
438
|
-
|
|
439
|
-
var describeComponentFrame = function (name, source, ownerName) {
|
|
440
|
-
var sourceInfo = '';
|
|
441
|
-
if (source) {
|
|
442
|
-
var path = source.fileName;
|
|
443
|
-
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
444
|
-
{
|
|
445
|
-
// In DEV, include code for a common special case:
|
|
446
|
-
// prefer "folder/index.js" instead of just "index.js".
|
|
447
|
-
if (/^index\./.test(fileName)) {
|
|
448
|
-
var match = path.match(BEFORE_SLASH_RE);
|
|
449
|
-
if (match) {
|
|
450
|
-
var pathBeforeSlash = match[1];
|
|
451
|
-
if (pathBeforeSlash) {
|
|
452
|
-
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
453
|
-
fileName = folderName + '/' + fileName;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
459
|
-
} else if (ownerName) {
|
|
460
|
-
sourceInfo = ' (created by ' + ownerName + ')';
|
|
461
|
-
}
|
|
462
|
-
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
var Resolved = 1;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
function refineResolvedLazyComponent(lazyComponent) {
|
|
469
|
-
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function getWrappedName(outerType, innerType, wrapperName) {
|
|
473
|
-
var functionName = innerType.displayName || innerType.name || '';
|
|
474
|
-
return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function getComponentName(type) {
|
|
478
|
-
if (type == null) {
|
|
479
|
-
// Host root, text node or just invalid type.
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
{
|
|
483
|
-
if (typeof type.tag === 'number') {
|
|
484
|
-
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (typeof type === 'function') {
|
|
488
|
-
return type.displayName || type.name || null;
|
|
489
|
-
}
|
|
490
|
-
if (typeof type === 'string') {
|
|
491
|
-
return type;
|
|
492
|
-
}
|
|
493
|
-
switch (type) {
|
|
494
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
495
|
-
return 'ConcurrentMode';
|
|
496
|
-
case REACT_FRAGMENT_TYPE:
|
|
497
|
-
return 'Fragment';
|
|
498
|
-
case REACT_PORTAL_TYPE:
|
|
499
|
-
return 'Portal';
|
|
500
|
-
case REACT_PROFILER_TYPE:
|
|
501
|
-
return 'Profiler';
|
|
502
|
-
case REACT_STRICT_MODE_TYPE:
|
|
503
|
-
return 'StrictMode';
|
|
504
|
-
case REACT_SUSPENSE_TYPE:
|
|
505
|
-
return 'Suspense';
|
|
506
|
-
}
|
|
507
|
-
if (typeof type === 'object') {
|
|
508
|
-
switch (type.$$typeof) {
|
|
509
|
-
case REACT_CONTEXT_TYPE:
|
|
510
|
-
return 'Context.Consumer';
|
|
511
|
-
case REACT_PROVIDER_TYPE:
|
|
512
|
-
return 'Context.Provider';
|
|
513
|
-
case REACT_FORWARD_REF_TYPE:
|
|
514
|
-
return getWrappedName(type, type.render, 'ForwardRef');
|
|
515
|
-
case REACT_MEMO_TYPE:
|
|
516
|
-
return getComponentName(type.type);
|
|
517
|
-
case REACT_LAZY_TYPE:
|
|
518
|
-
{
|
|
519
|
-
var thenable = type;
|
|
520
|
-
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
521
|
-
if (resolvedThenable) {
|
|
522
|
-
return getComponentName(resolvedThenable);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
var ReactDebugCurrentFrame = {};
|
|
531
|
-
|
|
532
|
-
var currentlyValidatingElement = null;
|
|
508
|
+
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
|
509
|
+
* we would like to deprecate them, we're not going to move them over to this
|
|
510
|
+
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
511
|
+
*/
|
|
533
512
|
|
|
534
|
-
function setCurrentlyValidatingElement(element) {
|
|
535
|
-
{
|
|
536
|
-
currentlyValidatingElement = element;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
513
|
|
|
540
514
|
{
|
|
541
|
-
|
|
542
|
-
|
|
515
|
+
var deprecatedAPIs = {
|
|
516
|
+
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
517
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
518
|
+
};
|
|
543
519
|
|
|
544
|
-
|
|
545
|
-
|
|
520
|
+
var defineDeprecationWarning = function (methodName, info) {
|
|
521
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
522
|
+
get: function () {
|
|
523
|
+
warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
|
546
524
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
552
|
-
}
|
|
525
|
+
return undefined;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
};
|
|
553
529
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
stack += impl() || '';
|
|
530
|
+
for (var fnName in deprecatedAPIs) {
|
|
531
|
+
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
532
|
+
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
558
533
|
}
|
|
559
|
-
|
|
560
|
-
return stack;
|
|
561
|
-
};
|
|
534
|
+
}
|
|
562
535
|
}
|
|
563
536
|
|
|
564
|
-
|
|
565
|
-
ReactCurrentDispatcher: ReactCurrentDispatcher,
|
|
566
|
-
ReactCurrentOwner: ReactCurrentOwner,
|
|
567
|
-
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
568
|
-
assign: _assign
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
{
|
|
572
|
-
_assign(ReactSharedInternals, {
|
|
573
|
-
// These should not be included in production.
|
|
574
|
-
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
|
575
|
-
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
|
576
|
-
// TODO: remove in React 17.0.
|
|
577
|
-
ReactComponentTreeHook: {}
|
|
578
|
-
});
|
|
579
|
-
}
|
|
537
|
+
function ComponentDummy() {}
|
|
580
538
|
|
|
539
|
+
ComponentDummy.prototype = Component.prototype;
|
|
581
540
|
/**
|
|
582
|
-
*
|
|
583
|
-
* This can be used to log issues in development environments in critical
|
|
584
|
-
* paths. Removing the logging code for production environments will keep the
|
|
585
|
-
* same logic and follow the same code paths.
|
|
541
|
+
* Convenience component with default shallow equality check for sCU.
|
|
586
542
|
*/
|
|
587
543
|
|
|
588
|
-
|
|
544
|
+
function PureComponent(props, context, updater) {
|
|
545
|
+
this.props = props;
|
|
546
|
+
this.context = context; // If a component has string refs, we will assign a different object later.
|
|
589
547
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
596
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
597
|
-
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
548
|
+
this.refs = emptyObject;
|
|
549
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
550
|
+
}
|
|
598
551
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
552
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
553
|
+
pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
|
|
554
|
+
|
|
555
|
+
_assign(pureComponentPrototype, Component.prototype);
|
|
556
|
+
|
|
557
|
+
pureComponentPrototype.isPureReactComponent = true;
|
|
602
558
|
|
|
603
|
-
|
|
559
|
+
// an immutable object with a single mutable value
|
|
560
|
+
function createRef() {
|
|
561
|
+
var refObject = {
|
|
562
|
+
current: null
|
|
604
563
|
};
|
|
605
|
-
}
|
|
606
564
|
|
|
607
|
-
|
|
565
|
+
{
|
|
566
|
+
Object.seal(refObject);
|
|
567
|
+
}
|
|
608
568
|
|
|
609
|
-
|
|
569
|
+
return refObject;
|
|
570
|
+
}
|
|
610
571
|
|
|
572
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
611
573
|
var RESERVED_PROPS = {
|
|
612
574
|
key: true,
|
|
613
575
|
ref: true,
|
|
614
576
|
__self: true,
|
|
615
577
|
__source: true
|
|
616
578
|
};
|
|
617
|
-
|
|
618
|
-
var
|
|
619
|
-
var specialPropRefWarningShown = void 0;
|
|
579
|
+
var specialPropKeyWarningShown;
|
|
580
|
+
var specialPropRefWarningShown;
|
|
620
581
|
|
|
621
582
|
function hasValidRef(config) {
|
|
622
583
|
{
|
|
623
584
|
if (hasOwnProperty.call(config, 'ref')) {
|
|
624
585
|
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
586
|
+
|
|
625
587
|
if (getter && getter.isReactWarning) {
|
|
626
588
|
return false;
|
|
627
589
|
}
|
|
628
590
|
}
|
|
629
591
|
}
|
|
592
|
+
|
|
630
593
|
return config.ref !== undefined;
|
|
631
594
|
}
|
|
632
595
|
|
|
@@ -634,21 +597,27 @@ function hasValidKey(config) {
|
|
|
634
597
|
{
|
|
635
598
|
if (hasOwnProperty.call(config, 'key')) {
|
|
636
599
|
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
600
|
+
|
|
637
601
|
if (getter && getter.isReactWarning) {
|
|
638
602
|
return false;
|
|
639
603
|
}
|
|
640
604
|
}
|
|
641
605
|
}
|
|
606
|
+
|
|
642
607
|
return config.key !== undefined;
|
|
643
608
|
}
|
|
644
609
|
|
|
645
610
|
function defineKeyPropWarningGetter(props, displayName) {
|
|
646
611
|
var warnAboutAccessingKey = function () {
|
|
647
|
-
|
|
648
|
-
specialPropKeyWarningShown
|
|
649
|
-
|
|
612
|
+
{
|
|
613
|
+
if (!specialPropKeyWarningShown) {
|
|
614
|
+
specialPropKeyWarningShown = true;
|
|
615
|
+
|
|
616
|
+
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://fb.me/react-special-props)', displayName);
|
|
617
|
+
}
|
|
650
618
|
}
|
|
651
619
|
};
|
|
620
|
+
|
|
652
621
|
warnAboutAccessingKey.isReactWarning = true;
|
|
653
622
|
Object.defineProperty(props, 'key', {
|
|
654
623
|
get: warnAboutAccessingKey,
|
|
@@ -658,27 +627,32 @@ function defineKeyPropWarningGetter(props, displayName) {
|
|
|
658
627
|
|
|
659
628
|
function defineRefPropWarningGetter(props, displayName) {
|
|
660
629
|
var warnAboutAccessingRef = function () {
|
|
661
|
-
|
|
662
|
-
specialPropRefWarningShown
|
|
663
|
-
|
|
630
|
+
{
|
|
631
|
+
if (!specialPropRefWarningShown) {
|
|
632
|
+
specialPropRefWarningShown = true;
|
|
633
|
+
|
|
634
|
+
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://fb.me/react-special-props)', displayName);
|
|
635
|
+
}
|
|
664
636
|
}
|
|
665
637
|
};
|
|
638
|
+
|
|
666
639
|
warnAboutAccessingRef.isReactWarning = true;
|
|
667
640
|
Object.defineProperty(props, 'ref', {
|
|
668
641
|
get: warnAboutAccessingRef,
|
|
669
642
|
configurable: true
|
|
670
643
|
});
|
|
671
644
|
}
|
|
672
|
-
|
|
673
645
|
/**
|
|
674
646
|
* Factory method to create a new React element. This no longer adheres to
|
|
675
|
-
* the class pattern, so do not use new to call it. Also,
|
|
676
|
-
* will work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
647
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
648
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
677
649
|
* if something is a React Element.
|
|
678
650
|
*
|
|
679
651
|
* @param {*} type
|
|
652
|
+
* @param {*} props
|
|
680
653
|
* @param {*} key
|
|
681
654
|
* @param {string|object} ref
|
|
655
|
+
* @param {*} owner
|
|
682
656
|
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
683
657
|
* different from the `owner` when React.createElement is called, so that we
|
|
684
658
|
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
@@ -686,21 +660,19 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
686
660
|
* change in behavior.
|
|
687
661
|
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
688
662
|
* indicating filename, line number, and/or other information.
|
|
689
|
-
* @param {*} owner
|
|
690
|
-
* @param {*} props
|
|
691
663
|
* @internal
|
|
692
664
|
*/
|
|
665
|
+
|
|
666
|
+
|
|
693
667
|
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
694
668
|
var element = {
|
|
695
669
|
// This tag allows us to uniquely identify this as a React Element
|
|
696
670
|
$$typeof: REACT_ELEMENT_TYPE,
|
|
697
|
-
|
|
698
671
|
// Built-in properties that belong on the element
|
|
699
672
|
type: type,
|
|
700
673
|
key: key,
|
|
701
674
|
ref: ref,
|
|
702
675
|
props: props,
|
|
703
|
-
|
|
704
676
|
// Record the component responsible for creating this element.
|
|
705
677
|
_owner: owner
|
|
706
678
|
};
|
|
@@ -710,33 +682,33 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
710
682
|
// an external backing store so that we can freeze the whole object.
|
|
711
683
|
// This can be replaced with a WeakMap once they are implemented in
|
|
712
684
|
// commonly used development environments.
|
|
713
|
-
element._store = {};
|
|
714
|
-
|
|
715
|
-
// To make comparing ReactElements easier for testing purposes, we make
|
|
685
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
716
686
|
// the validation flag non-enumerable (where possible, which should
|
|
717
687
|
// include every environment we run tests in), so the test framework
|
|
718
688
|
// ignores it.
|
|
689
|
+
|
|
719
690
|
Object.defineProperty(element._store, 'validated', {
|
|
720
691
|
configurable: false,
|
|
721
692
|
enumerable: false,
|
|
722
693
|
writable: true,
|
|
723
694
|
value: false
|
|
724
|
-
});
|
|
725
|
-
|
|
695
|
+
}); // self and source are DEV only properties.
|
|
696
|
+
|
|
726
697
|
Object.defineProperty(element, '_self', {
|
|
727
698
|
configurable: false,
|
|
728
699
|
enumerable: false,
|
|
729
700
|
writable: false,
|
|
730
701
|
value: self
|
|
731
|
-
});
|
|
732
|
-
// Two elements created in two different places should be considered
|
|
702
|
+
}); // Two elements created in two different places should be considered
|
|
733
703
|
// equal for testing purposes and therefore we hide it from enumeration.
|
|
704
|
+
|
|
734
705
|
Object.defineProperty(element, '_source', {
|
|
735
706
|
configurable: false,
|
|
736
707
|
enumerable: false,
|
|
737
708
|
writable: false,
|
|
738
709
|
value: source
|
|
739
710
|
});
|
|
711
|
+
|
|
740
712
|
if (Object.freeze) {
|
|
741
713
|
Object.freeze(element.props);
|
|
742
714
|
Object.freeze(element);
|
|
@@ -745,17 +717,87 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
745
717
|
|
|
746
718
|
return element;
|
|
747
719
|
};
|
|
720
|
+
/**
|
|
721
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
722
|
+
* @param {*} type
|
|
723
|
+
* @param {object} props
|
|
724
|
+
* @param {string} key
|
|
725
|
+
*/
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
731
|
+
* @param {*} type
|
|
732
|
+
* @param {object} props
|
|
733
|
+
* @param {string} key
|
|
734
|
+
*/
|
|
735
|
+
|
|
736
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
737
|
+
var propName; // Reserved names are extracted
|
|
738
|
+
|
|
739
|
+
var props = {};
|
|
740
|
+
var key = null;
|
|
741
|
+
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
742
|
+
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
743
|
+
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
744
|
+
// but as an intermediary step, we will use jsxDEV for everything except
|
|
745
|
+
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
746
|
+
// key is explicitly declared to be undefined or not.
|
|
747
|
+
|
|
748
|
+
if (maybeKey !== undefined) {
|
|
749
|
+
key = '' + maybeKey;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
if (hasValidKey(config)) {
|
|
753
|
+
key = '' + config.key;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (hasValidRef(config)) {
|
|
757
|
+
ref = config.ref;
|
|
758
|
+
} // Remaining properties are added to a new props object
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
for (propName in config) {
|
|
762
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
763
|
+
props[propName] = config[propName];
|
|
764
|
+
}
|
|
765
|
+
} // Resolve default props
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
if (type && type.defaultProps) {
|
|
769
|
+
var defaultProps = type.defaultProps;
|
|
770
|
+
|
|
771
|
+
for (propName in defaultProps) {
|
|
772
|
+
if (props[propName] === undefined) {
|
|
773
|
+
props[propName] = defaultProps[propName];
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
748
777
|
|
|
778
|
+
if (key || ref) {
|
|
779
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
780
|
+
|
|
781
|
+
if (key) {
|
|
782
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (ref) {
|
|
786
|
+
defineRefPropWarningGetter(props, displayName);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
791
|
+
}
|
|
749
792
|
/**
|
|
750
793
|
* Create and return a new ReactElement of the given type.
|
|
751
794
|
* See https://reactjs.org/docs/react-api.html#createelement
|
|
752
795
|
*/
|
|
796
|
+
|
|
753
797
|
function createElement(type, config, children) {
|
|
754
|
-
var propName
|
|
798
|
+
var propName; // Reserved names are extracted
|
|
755
799
|
|
|
756
|
-
// Reserved names are extracted
|
|
757
800
|
var props = {};
|
|
758
|
-
|
|
759
801
|
var key = null;
|
|
760
802
|
var ref = null;
|
|
761
803
|
var self = null;
|
|
@@ -765,61 +807,70 @@ function createElement(type, config, children) {
|
|
|
765
807
|
if (hasValidRef(config)) {
|
|
766
808
|
ref = config.ref;
|
|
767
809
|
}
|
|
810
|
+
|
|
768
811
|
if (hasValidKey(config)) {
|
|
769
812
|
key = '' + config.key;
|
|
770
813
|
}
|
|
771
814
|
|
|
772
815
|
self = config.__self === undefined ? null : config.__self;
|
|
773
|
-
source = config.__source === undefined ? null : config.__source;
|
|
774
|
-
|
|
816
|
+
source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
|
|
817
|
+
|
|
775
818
|
for (propName in config) {
|
|
776
819
|
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
777
820
|
props[propName] = config[propName];
|
|
778
821
|
}
|
|
779
822
|
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
// Children can be more than one argument, and those are transferred onto
|
|
823
|
+
} // Children can be more than one argument, and those are transferred onto
|
|
783
824
|
// the newly allocated props object.
|
|
825
|
+
|
|
826
|
+
|
|
784
827
|
var childrenLength = arguments.length - 2;
|
|
828
|
+
|
|
785
829
|
if (childrenLength === 1) {
|
|
786
830
|
props.children = children;
|
|
787
831
|
} else if (childrenLength > 1) {
|
|
788
832
|
var childArray = Array(childrenLength);
|
|
833
|
+
|
|
789
834
|
for (var i = 0; i < childrenLength; i++) {
|
|
790
835
|
childArray[i] = arguments[i + 2];
|
|
791
836
|
}
|
|
837
|
+
|
|
792
838
|
{
|
|
793
839
|
if (Object.freeze) {
|
|
794
840
|
Object.freeze(childArray);
|
|
795
841
|
}
|
|
796
842
|
}
|
|
843
|
+
|
|
797
844
|
props.children = childArray;
|
|
798
|
-
}
|
|
845
|
+
} // Resolve default props
|
|
846
|
+
|
|
799
847
|
|
|
800
|
-
// Resolve default props
|
|
801
848
|
if (type && type.defaultProps) {
|
|
802
849
|
var defaultProps = type.defaultProps;
|
|
850
|
+
|
|
803
851
|
for (propName in defaultProps) {
|
|
804
852
|
if (props[propName] === undefined) {
|
|
805
853
|
props[propName] = defaultProps[propName];
|
|
806
854
|
}
|
|
807
855
|
}
|
|
808
856
|
}
|
|
857
|
+
|
|
809
858
|
{
|
|
810
859
|
if (key || ref) {
|
|
811
860
|
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
861
|
+
|
|
812
862
|
if (key) {
|
|
813
863
|
defineKeyPropWarningGetter(props, displayName);
|
|
814
864
|
}
|
|
865
|
+
|
|
815
866
|
if (ref) {
|
|
816
867
|
defineRefPropWarningGetter(props, displayName);
|
|
817
868
|
}
|
|
818
869
|
}
|
|
819
870
|
}
|
|
871
|
+
|
|
820
872
|
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
821
873
|
}
|
|
822
|
-
|
|
823
874
|
/**
|
|
824
875
|
* Return a function that produces ReactElements of a given type.
|
|
825
876
|
* See https://reactjs.org/docs/react-api.html#createfactory
|
|
@@ -828,33 +879,34 @@ function createElement(type, config, children) {
|
|
|
828
879
|
|
|
829
880
|
function cloneAndReplaceKey(oldElement, newKey) {
|
|
830
881
|
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
|
831
|
-
|
|
832
882
|
return newElement;
|
|
833
883
|
}
|
|
834
|
-
|
|
835
884
|
/**
|
|
836
885
|
* Clone and return a new ReactElement using element as the starting point.
|
|
837
886
|
* See https://reactjs.org/docs/react-api.html#cloneelement
|
|
838
887
|
*/
|
|
888
|
+
|
|
839
889
|
function cloneElement(element, config, children) {
|
|
840
|
-
!!(element === null || element === undefined)
|
|
890
|
+
if (!!(element === null || element === undefined)) {
|
|
891
|
+
{
|
|
892
|
+
throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
|
|
893
|
+
}
|
|
894
|
+
}
|
|
841
895
|
|
|
842
|
-
var propName
|
|
896
|
+
var propName; // Original props are copied
|
|
897
|
+
|
|
898
|
+
var props = _assign({}, element.props); // Reserved names are extracted
|
|
843
899
|
|
|
844
|
-
// Original props are copied
|
|
845
|
-
var props = _assign({}, element.props);
|
|
846
900
|
|
|
847
|
-
// Reserved names are extracted
|
|
848
901
|
var key = element.key;
|
|
849
|
-
var ref = element.ref;
|
|
850
|
-
|
|
851
|
-
var self = element._self;
|
|
852
|
-
// Source is preserved since cloneElement is unlikely to be targeted by a
|
|
902
|
+
var ref = element.ref; // Self is preserved since the owner is preserved.
|
|
903
|
+
|
|
904
|
+
var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
|
|
853
905
|
// transpiler, and the original source is probably a better indicator of the
|
|
854
906
|
// true owner.
|
|
855
|
-
var source = element._source;
|
|
856
907
|
|
|
857
|
-
// Owner will be preserved, unless ref is overridden
|
|
908
|
+
var source = element._source; // Owner will be preserved, unless ref is overridden
|
|
909
|
+
|
|
858
910
|
var owner = element._owner;
|
|
859
911
|
|
|
860
912
|
if (config != null) {
|
|
@@ -863,15 +915,18 @@ function cloneElement(element, config, children) {
|
|
|
863
915
|
ref = config.ref;
|
|
864
916
|
owner = ReactCurrentOwner.current;
|
|
865
917
|
}
|
|
918
|
+
|
|
866
919
|
if (hasValidKey(config)) {
|
|
867
920
|
key = '' + config.key;
|
|
868
|
-
}
|
|
921
|
+
} // Remaining properties override existing props
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
var defaultProps;
|
|
869
925
|
|
|
870
|
-
// Remaining properties override existing props
|
|
871
|
-
var defaultProps = void 0;
|
|
872
926
|
if (element.type && element.type.defaultProps) {
|
|
873
927
|
defaultProps = element.type.defaultProps;
|
|
874
928
|
}
|
|
929
|
+
|
|
875
930
|
for (propName in config) {
|
|
876
931
|
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
877
932
|
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
@@ -882,24 +937,26 @@ function cloneElement(element, config, children) {
|
|
|
882
937
|
}
|
|
883
938
|
}
|
|
884
939
|
}
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
// Children can be more than one argument, and those are transferred onto
|
|
940
|
+
} // Children can be more than one argument, and those are transferred onto
|
|
888
941
|
// the newly allocated props object.
|
|
942
|
+
|
|
943
|
+
|
|
889
944
|
var childrenLength = arguments.length - 2;
|
|
945
|
+
|
|
890
946
|
if (childrenLength === 1) {
|
|
891
947
|
props.children = children;
|
|
892
948
|
} else if (childrenLength > 1) {
|
|
893
949
|
var childArray = Array(childrenLength);
|
|
950
|
+
|
|
894
951
|
for (var i = 0; i < childrenLength; i++) {
|
|
895
952
|
childArray[i] = arguments[i + 2];
|
|
896
953
|
}
|
|
954
|
+
|
|
897
955
|
props.children = childArray;
|
|
898
956
|
}
|
|
899
957
|
|
|
900
958
|
return ReactElement(element.type, key, ref, self, source, owner, props);
|
|
901
959
|
}
|
|
902
|
-
|
|
903
960
|
/**
|
|
904
961
|
* Verifies the object is a ReactElement.
|
|
905
962
|
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
@@ -907,19 +964,20 @@ function cloneElement(element, config, children) {
|
|
|
907
964
|
* @return {boolean} True if `object` is a ReactElement.
|
|
908
965
|
* @final
|
|
909
966
|
*/
|
|
967
|
+
|
|
910
968
|
function isValidElement(object) {
|
|
911
969
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
912
970
|
}
|
|
913
971
|
|
|
914
972
|
var SEPARATOR = '.';
|
|
915
973
|
var SUBSEPARATOR = ':';
|
|
916
|
-
|
|
917
974
|
/**
|
|
918
975
|
* Escape and wrap key so it is safe to use as a reactid
|
|
919
976
|
*
|
|
920
977
|
* @param {string} key to be escaped.
|
|
921
978
|
* @return {string} the escaped key.
|
|
922
979
|
*/
|
|
980
|
+
|
|
923
981
|
function escape(key) {
|
|
924
982
|
var escapeRegex = /[=:]/g;
|
|
925
983
|
var escaperLookup = {
|
|
@@ -929,24 +987,24 @@ function escape(key) {
|
|
|
929
987
|
var escapedString = ('' + key).replace(escapeRegex, function (match) {
|
|
930
988
|
return escaperLookup[match];
|
|
931
989
|
});
|
|
932
|
-
|
|
933
990
|
return '$' + escapedString;
|
|
934
991
|
}
|
|
935
|
-
|
|
936
992
|
/**
|
|
937
993
|
* TODO: Test that a single child and an array with one item have the same key
|
|
938
994
|
* pattern.
|
|
939
995
|
*/
|
|
940
996
|
|
|
941
|
-
var didWarnAboutMaps = false;
|
|
942
997
|
|
|
998
|
+
var didWarnAboutMaps = false;
|
|
943
999
|
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
1000
|
+
|
|
944
1001
|
function escapeUserProvidedKey(text) {
|
|
945
1002
|
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
|
946
1003
|
}
|
|
947
1004
|
|
|
948
1005
|
var POOL_SIZE = 10;
|
|
949
1006
|
var traverseContextPool = [];
|
|
1007
|
+
|
|
950
1008
|
function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
|
|
951
1009
|
if (traverseContextPool.length) {
|
|
952
1010
|
var traverseContext = traverseContextPool.pop();
|
|
@@ -973,11 +1031,11 @@ function releaseTraverseContext(traverseContext) {
|
|
|
973
1031
|
traverseContext.func = null;
|
|
974
1032
|
traverseContext.context = null;
|
|
975
1033
|
traverseContext.count = 0;
|
|
1034
|
+
|
|
976
1035
|
if (traverseContextPool.length < POOL_SIZE) {
|
|
977
1036
|
traverseContextPool.push(traverseContext);
|
|
978
1037
|
}
|
|
979
1038
|
}
|
|
980
|
-
|
|
981
1039
|
/**
|
|
982
1040
|
* @param {?*} children Children tree container.
|
|
983
1041
|
* @param {!string} nameSoFar Name of the key path so far.
|
|
@@ -986,6 +1044,8 @@ function releaseTraverseContext(traverseContext) {
|
|
|
986
1044
|
* process.
|
|
987
1045
|
* @return {!number} The number of children in this subtree.
|
|
988
1046
|
*/
|
|
1047
|
+
|
|
1048
|
+
|
|
989
1049
|
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
|
990
1050
|
var type = typeof children;
|
|
991
1051
|
|
|
@@ -1004,26 +1064,28 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1004
1064
|
case 'number':
|
|
1005
1065
|
invokeCallback = true;
|
|
1006
1066
|
break;
|
|
1067
|
+
|
|
1007
1068
|
case 'object':
|
|
1008
1069
|
switch (children.$$typeof) {
|
|
1009
1070
|
case REACT_ELEMENT_TYPE:
|
|
1010
1071
|
case REACT_PORTAL_TYPE:
|
|
1011
1072
|
invokeCallback = true;
|
|
1012
1073
|
}
|
|
1074
|
+
|
|
1013
1075
|
}
|
|
1014
1076
|
}
|
|
1015
1077
|
|
|
1016
1078
|
if (invokeCallback) {
|
|
1017
|
-
callback(traverseContext, children,
|
|
1018
|
-
// If it's the only child, treat the name as if it was wrapped in an array
|
|
1079
|
+
callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array
|
|
1019
1080
|
// so that it's consistent if the number of children grows.
|
|
1020
1081
|
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
|
|
1021
1082
|
return 1;
|
|
1022
1083
|
}
|
|
1023
1084
|
|
|
1024
|
-
var child
|
|
1025
|
-
var nextName
|
|
1085
|
+
var child;
|
|
1086
|
+
var nextName;
|
|
1026
1087
|
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
1088
|
+
|
|
1027
1089
|
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
1028
1090
|
|
|
1029
1091
|
if (Array.isArray(children)) {
|
|
@@ -1034,18 +1096,23 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1034
1096
|
}
|
|
1035
1097
|
} else {
|
|
1036
1098
|
var iteratorFn = getIteratorFn(children);
|
|
1099
|
+
|
|
1037
1100
|
if (typeof iteratorFn === 'function') {
|
|
1038
1101
|
{
|
|
1039
1102
|
// Warn about using Maps as children
|
|
1040
1103
|
if (iteratorFn === children.entries) {
|
|
1041
|
-
!didWarnAboutMaps
|
|
1104
|
+
if (!didWarnAboutMaps) {
|
|
1105
|
+
error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1042
1108
|
didWarnAboutMaps = true;
|
|
1043
1109
|
}
|
|
1044
1110
|
}
|
|
1045
1111
|
|
|
1046
1112
|
var iterator = iteratorFn.call(children);
|
|
1047
|
-
var step
|
|
1113
|
+
var step;
|
|
1048
1114
|
var ii = 0;
|
|
1115
|
+
|
|
1049
1116
|
while (!(step = iterator.next()).done) {
|
|
1050
1117
|
child = step.value;
|
|
1051
1118
|
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
|
@@ -1053,17 +1120,23 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1053
1120
|
}
|
|
1054
1121
|
} else if (type === 'object') {
|
|
1055
1122
|
var addendum = '';
|
|
1123
|
+
|
|
1056
1124
|
{
|
|
1057
1125
|
addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
|
|
1058
1126
|
}
|
|
1127
|
+
|
|
1059
1128
|
var childrenString = '' + children;
|
|
1060
|
-
|
|
1129
|
+
|
|
1130
|
+
{
|
|
1131
|
+
{
|
|
1132
|
+
throw Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1061
1135
|
}
|
|
1062
1136
|
}
|
|
1063
1137
|
|
|
1064
1138
|
return subtreeCount;
|
|
1065
1139
|
}
|
|
1066
|
-
|
|
1067
1140
|
/**
|
|
1068
1141
|
* Traverses children that are typically specified as `props.children`, but
|
|
1069
1142
|
* might also be specified through attributes:
|
|
@@ -1080,6 +1153,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1080
1153
|
* @param {?*} traverseContext Context for traversal.
|
|
1081
1154
|
* @return {!number} The number of children in this subtree.
|
|
1082
1155
|
*/
|
|
1156
|
+
|
|
1157
|
+
|
|
1083
1158
|
function traverseAllChildren(children, callback, traverseContext) {
|
|
1084
1159
|
if (children == null) {
|
|
1085
1160
|
return 0;
|
|
@@ -1087,7 +1162,6 @@ function traverseAllChildren(children, callback, traverseContext) {
|
|
|
1087
1162
|
|
|
1088
1163
|
return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
|
1089
1164
|
}
|
|
1090
|
-
|
|
1091
1165
|
/**
|
|
1092
1166
|
* Generate a key string that identifies a component within a set.
|
|
1093
1167
|
*
|
|
@@ -1095,24 +1169,25 @@ function traverseAllChildren(children, callback, traverseContext) {
|
|
|
1095
1169
|
* @param {number} index Index that is used if a manual key is not provided.
|
|
1096
1170
|
* @return {string}
|
|
1097
1171
|
*/
|
|
1172
|
+
|
|
1173
|
+
|
|
1098
1174
|
function getComponentKey(component, index) {
|
|
1099
1175
|
// Do some typechecking here since we call this blindly. We want to ensure
|
|
1100
1176
|
// that we don't block potential future ES APIs.
|
|
1101
1177
|
if (typeof component === 'object' && component !== null && component.key != null) {
|
|
1102
1178
|
// Explicit key
|
|
1103
1179
|
return escape(component.key);
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1180
|
+
} // Implicit key determined by the index in the set
|
|
1181
|
+
|
|
1182
|
+
|
|
1106
1183
|
return index.toString(36);
|
|
1107
1184
|
}
|
|
1108
1185
|
|
|
1109
1186
|
function forEachSingleChild(bookKeeping, child, name) {
|
|
1110
1187
|
var func = bookKeeping.func,
|
|
1111
1188
|
context = bookKeeping.context;
|
|
1112
|
-
|
|
1113
1189
|
func.call(context, child, bookKeeping.count++);
|
|
1114
1190
|
}
|
|
1115
|
-
|
|
1116
1191
|
/**
|
|
1117
1192
|
* Iterates through children that are typically specified as `props.children`.
|
|
1118
1193
|
*
|
|
@@ -1125,10 +1200,13 @@ function forEachSingleChild(bookKeeping, child, name) {
|
|
|
1125
1200
|
* @param {function(*, int)} forEachFunc
|
|
1126
1201
|
* @param {*} forEachContext Context for forEachContext.
|
|
1127
1202
|
*/
|
|
1203
|
+
|
|
1204
|
+
|
|
1128
1205
|
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
1129
1206
|
if (children == null) {
|
|
1130
1207
|
return children;
|
|
1131
1208
|
}
|
|
1209
|
+
|
|
1132
1210
|
var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
|
|
1133
1211
|
traverseAllChildren(children, forEachSingleChild, traverseContext);
|
|
1134
1212
|
releaseTraverseContext(traverseContext);
|
|
@@ -1139,34 +1217,34 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
|
1139
1217
|
keyPrefix = bookKeeping.keyPrefix,
|
|
1140
1218
|
func = bookKeeping.func,
|
|
1141
1219
|
context = bookKeeping.context;
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
1220
|
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
1221
|
+
|
|
1145
1222
|
if (Array.isArray(mappedChild)) {
|
|
1146
1223
|
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
|
|
1147
1224
|
return c;
|
|
1148
1225
|
});
|
|
1149
1226
|
} else if (mappedChild != null) {
|
|
1150
1227
|
if (isValidElement(mappedChild)) {
|
|
1151
|
-
mappedChild = cloneAndReplaceKey(mappedChild,
|
|
1152
|
-
// Keep both the (mapped) and old keys if they differ, just as
|
|
1228
|
+
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
|
|
1153
1229
|
// traverseAllChildren used to do for objects as children
|
|
1154
1230
|
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
|
1155
1231
|
}
|
|
1232
|
+
|
|
1156
1233
|
result.push(mappedChild);
|
|
1157
1234
|
}
|
|
1158
1235
|
}
|
|
1159
1236
|
|
|
1160
1237
|
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
1161
1238
|
var escapedPrefix = '';
|
|
1239
|
+
|
|
1162
1240
|
if (prefix != null) {
|
|
1163
1241
|
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
|
1164
1242
|
}
|
|
1243
|
+
|
|
1165
1244
|
var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
|
|
1166
1245
|
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
|
1167
1246
|
releaseTraverseContext(traverseContext);
|
|
1168
1247
|
}
|
|
1169
|
-
|
|
1170
1248
|
/**
|
|
1171
1249
|
* Maps children that are typically specified as `props.children`.
|
|
1172
1250
|
*
|
|
@@ -1180,15 +1258,17 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
|
1180
1258
|
* @param {*} context Context for mapFunction.
|
|
1181
1259
|
* @return {object} Object containing the ordered map of results.
|
|
1182
1260
|
*/
|
|
1261
|
+
|
|
1262
|
+
|
|
1183
1263
|
function mapChildren(children, func, context) {
|
|
1184
1264
|
if (children == null) {
|
|
1185
1265
|
return children;
|
|
1186
1266
|
}
|
|
1267
|
+
|
|
1187
1268
|
var result = [];
|
|
1188
1269
|
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
|
1189
1270
|
return result;
|
|
1190
1271
|
}
|
|
1191
|
-
|
|
1192
1272
|
/**
|
|
1193
1273
|
* Count the number of children that are typically specified as
|
|
1194
1274
|
* `props.children`.
|
|
@@ -1198,18 +1278,21 @@ function mapChildren(children, func, context) {
|
|
|
1198
1278
|
* @param {?*} children Children tree container.
|
|
1199
1279
|
* @return {number} The number of children.
|
|
1200
1280
|
*/
|
|
1281
|
+
|
|
1282
|
+
|
|
1201
1283
|
function countChildren(children) {
|
|
1202
1284
|
return traverseAllChildren(children, function () {
|
|
1203
1285
|
return null;
|
|
1204
1286
|
}, null);
|
|
1205
1287
|
}
|
|
1206
|
-
|
|
1207
1288
|
/**
|
|
1208
1289
|
* Flatten a children object (typically specified as `props.children`) and
|
|
1209
1290
|
* return an array with appropriately re-keyed children.
|
|
1210
1291
|
*
|
|
1211
1292
|
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
|
|
1212
1293
|
*/
|
|
1294
|
+
|
|
1295
|
+
|
|
1213
1296
|
function toArray(children) {
|
|
1214
1297
|
var result = [];
|
|
1215
1298
|
mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
|
|
@@ -1217,7 +1300,6 @@ function toArray(children) {
|
|
|
1217
1300
|
});
|
|
1218
1301
|
return result;
|
|
1219
1302
|
}
|
|
1220
|
-
|
|
1221
1303
|
/**
|
|
1222
1304
|
* Returns the first child in a collection of children and verifies that there
|
|
1223
1305
|
* is only one child in the collection.
|
|
@@ -1232,8 +1314,15 @@ function toArray(children) {
|
|
|
1232
1314
|
* @return {ReactElement} The first and only `ReactElement` contained in the
|
|
1233
1315
|
* structure.
|
|
1234
1316
|
*/
|
|
1317
|
+
|
|
1318
|
+
|
|
1235
1319
|
function onlyChild(children) {
|
|
1236
|
-
!isValidElement(children)
|
|
1320
|
+
if (!isValidElement(children)) {
|
|
1321
|
+
{
|
|
1322
|
+
throw Error("React.Children.only expected to receive a single React element child.");
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1237
1326
|
return children;
|
|
1238
1327
|
}
|
|
1239
1328
|
|
|
@@ -1242,7 +1331,9 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1242
1331
|
calculateChangedBits = null;
|
|
1243
1332
|
} else {
|
|
1244
1333
|
{
|
|
1245
|
-
|
|
1334
|
+
if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
|
|
1335
|
+
error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
|
|
1336
|
+
}
|
|
1246
1337
|
}
|
|
1247
1338
|
}
|
|
1248
1339
|
|
|
@@ -1263,12 +1354,10 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1263
1354
|
Provider: null,
|
|
1264
1355
|
Consumer: null
|
|
1265
1356
|
};
|
|
1266
|
-
|
|
1267
1357
|
context.Provider = {
|
|
1268
1358
|
$$typeof: REACT_PROVIDER_TYPE,
|
|
1269
1359
|
_context: context
|
|
1270
1360
|
};
|
|
1271
|
-
|
|
1272
1361
|
var hasWarnedAboutUsingNestedContextConsumers = false;
|
|
1273
1362
|
var hasWarnedAboutUsingConsumerProvider = false;
|
|
1274
1363
|
|
|
@@ -1280,15 +1369,17 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1280
1369
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
1281
1370
|
_context: context,
|
|
1282
1371
|
_calculateChangedBits: context._calculateChangedBits
|
|
1283
|
-
};
|
|
1284
|
-
|
|
1372
|
+
}; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
|
|
1373
|
+
|
|
1285
1374
|
Object.defineProperties(Consumer, {
|
|
1286
1375
|
Provider: {
|
|
1287
1376
|
get: function () {
|
|
1288
1377
|
if (!hasWarnedAboutUsingConsumerProvider) {
|
|
1289
1378
|
hasWarnedAboutUsingConsumerProvider = true;
|
|
1290
|
-
|
|
1379
|
+
|
|
1380
|
+
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?');
|
|
1291
1381
|
}
|
|
1382
|
+
|
|
1292
1383
|
return context.Provider;
|
|
1293
1384
|
},
|
|
1294
1385
|
set: function (_Provider) {
|
|
@@ -1323,13 +1414,15 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1323
1414
|
get: function () {
|
|
1324
1415
|
if (!hasWarnedAboutUsingNestedContextConsumers) {
|
|
1325
1416
|
hasWarnedAboutUsingNestedContextConsumers = true;
|
|
1326
|
-
|
|
1417
|
+
|
|
1418
|
+
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?');
|
|
1327
1419
|
}
|
|
1420
|
+
|
|
1328
1421
|
return context.Consumer;
|
|
1329
1422
|
}
|
|
1330
1423
|
}
|
|
1331
|
-
});
|
|
1332
|
-
|
|
1424
|
+
}); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
|
|
1425
|
+
|
|
1333
1426
|
context.Consumer = Consumer;
|
|
1334
1427
|
}
|
|
1335
1428
|
|
|
@@ -1352,8 +1445,8 @@ function lazy(ctor) {
|
|
|
1352
1445
|
|
|
1353
1446
|
{
|
|
1354
1447
|
// In production, this would just set it on the object.
|
|
1355
|
-
var defaultProps
|
|
1356
|
-
var propTypes
|
|
1448
|
+
var defaultProps;
|
|
1449
|
+
var propTypes;
|
|
1357
1450
|
Object.defineProperties(lazyType, {
|
|
1358
1451
|
defaultProps: {
|
|
1359
1452
|
configurable: true,
|
|
@@ -1361,9 +1454,10 @@ function lazy(ctor) {
|
|
|
1361
1454
|
return defaultProps;
|
|
1362
1455
|
},
|
|
1363
1456
|
set: function (newDefaultProps) {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
// Match production behavior more closely:
|
|
1457
|
+
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.');
|
|
1458
|
+
|
|
1459
|
+
defaultProps = newDefaultProps; // Match production behavior more closely:
|
|
1460
|
+
|
|
1367
1461
|
Object.defineProperty(lazyType, 'defaultProps', {
|
|
1368
1462
|
enumerable: true
|
|
1369
1463
|
});
|
|
@@ -1375,9 +1469,10 @@ function lazy(ctor) {
|
|
|
1375
1469
|
return propTypes;
|
|
1376
1470
|
},
|
|
1377
1471
|
set: function (newPropTypes) {
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
// Match production behavior more closely:
|
|
1472
|
+
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.');
|
|
1473
|
+
|
|
1474
|
+
propTypes = newPropTypes; // Match production behavior more closely:
|
|
1475
|
+
|
|
1381
1476
|
Object.defineProperty(lazyType, 'propTypes', {
|
|
1382
1477
|
enumerable: true
|
|
1383
1478
|
});
|
|
@@ -1392,17 +1487,19 @@ function lazy(ctor) {
|
|
|
1392
1487
|
function forwardRef(render) {
|
|
1393
1488
|
{
|
|
1394
1489
|
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
|
|
1395
|
-
|
|
1490
|
+
error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
|
|
1396
1491
|
} else if (typeof render !== 'function') {
|
|
1397
|
-
|
|
1492
|
+
error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
|
1398
1493
|
} else {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1494
|
+
if (render.length !== 0 && render.length !== 2) {
|
|
1495
|
+
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.');
|
|
1496
|
+
}
|
|
1402
1497
|
}
|
|
1403
1498
|
|
|
1404
1499
|
if (render != null) {
|
|
1405
|
-
|
|
1500
|
+
if (render.defaultProps != null || render.propTypes != null) {
|
|
1501
|
+
error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
|
|
1502
|
+
}
|
|
1406
1503
|
}
|
|
1407
1504
|
}
|
|
1408
1505
|
|
|
@@ -1413,17 +1510,17 @@ function forwardRef(render) {
|
|
|
1413
1510
|
}
|
|
1414
1511
|
|
|
1415
1512
|
function isValidElementType(type) {
|
|
1416
|
-
return typeof type === 'string' || typeof type === 'function' ||
|
|
1417
|
-
|
|
1418
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (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);
|
|
1513
|
+
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1514
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
|
|
1419
1515
|
}
|
|
1420
1516
|
|
|
1421
1517
|
function memo(type, compare) {
|
|
1422
1518
|
{
|
|
1423
1519
|
if (!isValidElementType(type)) {
|
|
1424
|
-
|
|
1520
|
+
error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
|
|
1425
1521
|
}
|
|
1426
1522
|
}
|
|
1523
|
+
|
|
1427
1524
|
return {
|
|
1428
1525
|
$$typeof: REACT_MEMO_TYPE,
|
|
1429
1526
|
type: type,
|
|
@@ -1433,76 +1530,110 @@ function memo(type, compare) {
|
|
|
1433
1530
|
|
|
1434
1531
|
function resolveDispatcher() {
|
|
1435
1532
|
var dispatcher = ReactCurrentDispatcher.current;
|
|
1436
|
-
|
|
1533
|
+
|
|
1534
|
+
if (!(dispatcher !== null)) {
|
|
1535
|
+
{
|
|
1536
|
+
throw 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:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.");
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1437
1540
|
return dispatcher;
|
|
1438
1541
|
}
|
|
1439
1542
|
|
|
1440
1543
|
function useContext(Context, unstable_observedBits) {
|
|
1441
1544
|
var dispatcher = resolveDispatcher();
|
|
1545
|
+
|
|
1442
1546
|
{
|
|
1443
|
-
|
|
1547
|
+
if (unstable_observedBits !== undefined) {
|
|
1548
|
+
error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '');
|
|
1549
|
+
} // TODO: add a more generic warning for invalid values.
|
|
1550
|
+
|
|
1444
1551
|
|
|
1445
|
-
// TODO: add a more generic warning for invalid values.
|
|
1446
1552
|
if (Context._context !== undefined) {
|
|
1447
|
-
var realContext = Context._context;
|
|
1448
|
-
// Don't deduplicate because this legitimately causes bugs
|
|
1553
|
+
var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
|
|
1449
1554
|
// and nobody should be using this in existing code.
|
|
1555
|
+
|
|
1450
1556
|
if (realContext.Consumer === Context) {
|
|
1451
|
-
|
|
1557
|
+
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?');
|
|
1452
1558
|
} else if (realContext.Provider === Context) {
|
|
1453
|
-
|
|
1559
|
+
error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
|
|
1454
1560
|
}
|
|
1455
1561
|
}
|
|
1456
1562
|
}
|
|
1563
|
+
|
|
1457
1564
|
return dispatcher.useContext(Context, unstable_observedBits);
|
|
1458
1565
|
}
|
|
1459
|
-
|
|
1460
1566
|
function useState(initialState) {
|
|
1461
1567
|
var dispatcher = resolveDispatcher();
|
|
1462
1568
|
return dispatcher.useState(initialState);
|
|
1463
1569
|
}
|
|
1464
|
-
|
|
1465
1570
|
function useReducer(reducer, initialArg, init) {
|
|
1466
1571
|
var dispatcher = resolveDispatcher();
|
|
1467
1572
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1468
1573
|
}
|
|
1469
|
-
|
|
1470
1574
|
function useRef(initialValue) {
|
|
1471
1575
|
var dispatcher = resolveDispatcher();
|
|
1472
1576
|
return dispatcher.useRef(initialValue);
|
|
1473
1577
|
}
|
|
1474
|
-
|
|
1475
1578
|
function useEffect(create, inputs) {
|
|
1476
1579
|
var dispatcher = resolveDispatcher();
|
|
1477
1580
|
return dispatcher.useEffect(create, inputs);
|
|
1478
1581
|
}
|
|
1479
|
-
|
|
1480
1582
|
function useLayoutEffect(create, inputs) {
|
|
1481
1583
|
var dispatcher = resolveDispatcher();
|
|
1482
1584
|
return dispatcher.useLayoutEffect(create, inputs);
|
|
1483
1585
|
}
|
|
1484
|
-
|
|
1485
1586
|
function useCallback(callback, inputs) {
|
|
1486
1587
|
var dispatcher = resolveDispatcher();
|
|
1487
1588
|
return dispatcher.useCallback(callback, inputs);
|
|
1488
1589
|
}
|
|
1489
|
-
|
|
1490
1590
|
function useMemo(create, inputs) {
|
|
1491
1591
|
var dispatcher = resolveDispatcher();
|
|
1492
1592
|
return dispatcher.useMemo(create, inputs);
|
|
1493
1593
|
}
|
|
1494
|
-
|
|
1495
1594
|
function useImperativeHandle(ref, create, inputs) {
|
|
1496
1595
|
var dispatcher = resolveDispatcher();
|
|
1497
1596
|
return dispatcher.useImperativeHandle(ref, create, inputs);
|
|
1498
1597
|
}
|
|
1499
|
-
|
|
1500
1598
|
function useDebugValue(value, formatterFn) {
|
|
1501
1599
|
{
|
|
1502
1600
|
var dispatcher = resolveDispatcher();
|
|
1503
1601
|
return dispatcher.useDebugValue(value, formatterFn);
|
|
1504
1602
|
}
|
|
1505
1603
|
}
|
|
1604
|
+
var emptyObject$1 = {};
|
|
1605
|
+
function useResponder(responder, listenerProps) {
|
|
1606
|
+
var dispatcher = resolveDispatcher();
|
|
1607
|
+
|
|
1608
|
+
{
|
|
1609
|
+
if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) {
|
|
1610
|
+
error('useResponder: invalid first argument. Expected an event responder, but instead got %s', responder);
|
|
1611
|
+
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
return dispatcher.useResponder(responder, listenerProps || emptyObject$1);
|
|
1617
|
+
}
|
|
1618
|
+
function useTransition(config) {
|
|
1619
|
+
var dispatcher = resolveDispatcher();
|
|
1620
|
+
return dispatcher.useTransition(config);
|
|
1621
|
+
}
|
|
1622
|
+
function useDeferredValue(value, config) {
|
|
1623
|
+
var dispatcher = resolveDispatcher();
|
|
1624
|
+
return dispatcher.useDeferredValue(value, config);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
function withSuspenseConfig(scope, config) {
|
|
1628
|
+
var previousConfig = ReactCurrentBatchConfig.suspense;
|
|
1629
|
+
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
|
|
1630
|
+
|
|
1631
|
+
try {
|
|
1632
|
+
scope();
|
|
1633
|
+
} finally {
|
|
1634
|
+
ReactCurrentBatchConfig.suspense = previousConfig;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1506
1637
|
|
|
1507
1638
|
/**
|
|
1508
1639
|
* ReactElementValidator provides a wrapper around a element factory
|
|
@@ -1510,38 +1641,50 @@ function useDebugValue(value, formatterFn) {
|
|
|
1510
1641
|
* used only in DEV and could be replaced by a static type checker for languages
|
|
1511
1642
|
* that support it.
|
|
1512
1643
|
*/
|
|
1513
|
-
|
|
1514
|
-
var propTypesMisspellWarningShown = void 0;
|
|
1644
|
+
var propTypesMisspellWarningShown;
|
|
1515
1645
|
|
|
1516
1646
|
{
|
|
1517
1647
|
propTypesMisspellWarningShown = false;
|
|
1518
1648
|
}
|
|
1519
1649
|
|
|
1650
|
+
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1651
|
+
|
|
1520
1652
|
function getDeclarationErrorAddendum() {
|
|
1521
1653
|
if (ReactCurrentOwner.current) {
|
|
1522
1654
|
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
1655
|
+
|
|
1523
1656
|
if (name) {
|
|
1524
1657
|
return '\n\nCheck the render method of `' + name + '`.';
|
|
1525
1658
|
}
|
|
1526
1659
|
}
|
|
1660
|
+
|
|
1527
1661
|
return '';
|
|
1528
1662
|
}
|
|
1529
1663
|
|
|
1530
|
-
function getSourceInfoErrorAddendum(
|
|
1531
|
-
if (
|
|
1532
|
-
var source = elementProps.__source;
|
|
1664
|
+
function getSourceInfoErrorAddendum(source) {
|
|
1665
|
+
if (source !== undefined) {
|
|
1533
1666
|
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
1534
1667
|
var lineNumber = source.lineNumber;
|
|
1535
1668
|
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
1536
1669
|
}
|
|
1670
|
+
|
|
1537
1671
|
return '';
|
|
1538
1672
|
}
|
|
1539
1673
|
|
|
1674
|
+
function getSourceInfoErrorAddendumForProps(elementProps) {
|
|
1675
|
+
if (elementProps !== null && elementProps !== undefined) {
|
|
1676
|
+
return getSourceInfoErrorAddendum(elementProps.__source);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
return '';
|
|
1680
|
+
}
|
|
1540
1681
|
/**
|
|
1541
1682
|
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
1542
1683
|
* object keys are not valid. This allows us to keep track of children between
|
|
1543
1684
|
* updates.
|
|
1544
1685
|
*/
|
|
1686
|
+
|
|
1687
|
+
|
|
1545
1688
|
var ownerHasKeyUseWarning = {};
|
|
1546
1689
|
|
|
1547
1690
|
function getCurrentComponentErrorInfo(parentType) {
|
|
@@ -1549,13 +1692,14 @@ function getCurrentComponentErrorInfo(parentType) {
|
|
|
1549
1692
|
|
|
1550
1693
|
if (!info) {
|
|
1551
1694
|
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
1695
|
+
|
|
1552
1696
|
if (parentName) {
|
|
1553
|
-
info =
|
|
1697
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1554
1698
|
}
|
|
1555
1699
|
}
|
|
1700
|
+
|
|
1556
1701
|
return info;
|
|
1557
1702
|
}
|
|
1558
|
-
|
|
1559
1703
|
/**
|
|
1560
1704
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
1561
1705
|
* This element is in an array. The array could grow and shrink or be
|
|
@@ -1567,34 +1711,39 @@ function getCurrentComponentErrorInfo(parentType) {
|
|
|
1567
1711
|
* @param {ReactElement} element Element that requires a key.
|
|
1568
1712
|
* @param {*} parentType element's parent's type.
|
|
1569
1713
|
*/
|
|
1714
|
+
|
|
1715
|
+
|
|
1570
1716
|
function validateExplicitKey(element, parentType) {
|
|
1571
1717
|
if (!element._store || element._store.validated || element.key != null) {
|
|
1572
1718
|
return;
|
|
1573
1719
|
}
|
|
1574
|
-
element._store.validated = true;
|
|
1575
1720
|
|
|
1721
|
+
element._store.validated = true;
|
|
1576
1722
|
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
1723
|
+
|
|
1577
1724
|
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
1578
1725
|
return;
|
|
1579
1726
|
}
|
|
1580
|
-
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
1581
1727
|
|
|
1582
|
-
// Usually the current owner is the offender, but if it accepts children as a
|
|
1728
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
1583
1729
|
// property, it may be the creator of the child that's responsible for
|
|
1584
1730
|
// assigning it a key.
|
|
1731
|
+
|
|
1585
1732
|
var childOwner = '';
|
|
1733
|
+
|
|
1586
1734
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
1587
1735
|
// Give the component that originally created this child.
|
|
1588
|
-
childOwner =
|
|
1736
|
+
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
1589
1737
|
}
|
|
1590
1738
|
|
|
1591
1739
|
setCurrentlyValidatingElement(element);
|
|
1740
|
+
|
|
1592
1741
|
{
|
|
1593
|
-
|
|
1742
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1594
1743
|
}
|
|
1744
|
+
|
|
1595
1745
|
setCurrentlyValidatingElement(null);
|
|
1596
1746
|
}
|
|
1597
|
-
|
|
1598
1747
|
/**
|
|
1599
1748
|
* Ensure that every element either is passed in a static location, in an
|
|
1600
1749
|
* array with an explicit keys property defined, or in an object literal
|
|
@@ -1604,13 +1753,17 @@ function validateExplicitKey(element, parentType) {
|
|
|
1604
1753
|
* @param {ReactNode} node Statically passed child of any type.
|
|
1605
1754
|
* @param {*} parentType node's parent's type.
|
|
1606
1755
|
*/
|
|
1756
|
+
|
|
1757
|
+
|
|
1607
1758
|
function validateChildKeys(node, parentType) {
|
|
1608
1759
|
if (typeof node !== 'object') {
|
|
1609
1760
|
return;
|
|
1610
1761
|
}
|
|
1762
|
+
|
|
1611
1763
|
if (Array.isArray(node)) {
|
|
1612
1764
|
for (var i = 0; i < node.length; i++) {
|
|
1613
1765
|
var child = node[i];
|
|
1766
|
+
|
|
1614
1767
|
if (isValidElement(child)) {
|
|
1615
1768
|
validateExplicitKey(child, parentType);
|
|
1616
1769
|
}
|
|
@@ -1622,12 +1775,14 @@ function validateChildKeys(node, parentType) {
|
|
|
1622
1775
|
}
|
|
1623
1776
|
} else if (node) {
|
|
1624
1777
|
var iteratorFn = getIteratorFn(node);
|
|
1778
|
+
|
|
1625
1779
|
if (typeof iteratorFn === 'function') {
|
|
1626
1780
|
// Entry iterators used to provide implicit keys,
|
|
1627
1781
|
// but now we print a separate warning for them later.
|
|
1628
1782
|
if (iteratorFn !== node.entries) {
|
|
1629
1783
|
var iterator = iteratorFn.call(node);
|
|
1630
|
-
var step
|
|
1784
|
+
var step;
|
|
1785
|
+
|
|
1631
1786
|
while (!(step = iterator.next()).done) {
|
|
1632
1787
|
if (isValidElement(step.value)) {
|
|
1633
1788
|
validateExplicitKey(step.value, parentType);
|
|
@@ -1637,112 +1792,225 @@ function validateChildKeys(node, parentType) {
|
|
|
1637
1792
|
}
|
|
1638
1793
|
}
|
|
1639
1794
|
}
|
|
1640
|
-
|
|
1641
1795
|
/**
|
|
1642
1796
|
* Given an element, validate that its props follow the propTypes definition,
|
|
1643
1797
|
* provided by the type.
|
|
1644
1798
|
*
|
|
1645
1799
|
* @param {ReactElement} element
|
|
1646
1800
|
*/
|
|
1801
|
+
|
|
1802
|
+
|
|
1647
1803
|
function validatePropTypes(element) {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1804
|
+
{
|
|
1805
|
+
var type = element.type;
|
|
1806
|
+
|
|
1807
|
+
if (type === null || type === undefined || typeof type === 'string') {
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
var name = getComponentName(type);
|
|
1812
|
+
var propTypes;
|
|
1813
|
+
|
|
1814
|
+
if (typeof type === 'function') {
|
|
1815
|
+
propTypes = type.propTypes;
|
|
1816
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
1817
|
+
// Inner props are checked in the reconciler.
|
|
1818
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
1819
|
+
propTypes = type.propTypes;
|
|
1820
|
+
} else {
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
if (propTypes) {
|
|
1825
|
+
setCurrentlyValidatingElement(element);
|
|
1826
|
+
checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
|
1827
|
+
setCurrentlyValidatingElement(null);
|
|
1828
|
+
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1829
|
+
propTypesMisspellWarningShown = true;
|
|
1830
|
+
|
|
1831
|
+
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
1835
|
+
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
1836
|
+
}
|
|
1674
1837
|
}
|
|
1675
1838
|
}
|
|
1676
|
-
|
|
1677
1839
|
/**
|
|
1678
1840
|
* Given a fragment, validate that it can only be provided with fragment props
|
|
1679
1841
|
* @param {ReactElement} fragment
|
|
1680
1842
|
*/
|
|
1843
|
+
|
|
1844
|
+
|
|
1681
1845
|
function validateFragmentProps(fragment) {
|
|
1682
|
-
|
|
1846
|
+
{
|
|
1847
|
+
setCurrentlyValidatingElement(fragment);
|
|
1848
|
+
var keys = Object.keys(fragment.props);
|
|
1849
|
+
|
|
1850
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1851
|
+
var key = keys[i];
|
|
1852
|
+
|
|
1853
|
+
if (key !== 'children' && key !== 'key') {
|
|
1854
|
+
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1683
1855
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
var key = keys[i];
|
|
1687
|
-
if (key !== 'children' && key !== 'key') {
|
|
1688
|
-
warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1689
|
-
break;
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1690
1858
|
}
|
|
1691
|
-
}
|
|
1692
1859
|
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1860
|
+
if (fragment.ref !== null) {
|
|
1861
|
+
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1862
|
+
}
|
|
1696
1863
|
|
|
1697
|
-
|
|
1864
|
+
setCurrentlyValidatingElement(null);
|
|
1865
|
+
}
|
|
1698
1866
|
}
|
|
1699
1867
|
|
|
1700
|
-
function
|
|
1701
|
-
var validType = isValidElementType(type);
|
|
1702
|
-
|
|
1703
|
-
// We warn in this case but don't throw. We expect the element creation to
|
|
1868
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
1869
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
1704
1870
|
// succeed and there will likely be errors in render.
|
|
1871
|
+
|
|
1705
1872
|
if (!validType) {
|
|
1706
1873
|
var info = '';
|
|
1874
|
+
|
|
1707
1875
|
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1708
1876
|
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.";
|
|
1709
1877
|
}
|
|
1710
1878
|
|
|
1711
|
-
var sourceInfo = getSourceInfoErrorAddendum(
|
|
1879
|
+
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
1880
|
+
|
|
1712
1881
|
if (sourceInfo) {
|
|
1713
1882
|
info += sourceInfo;
|
|
1714
1883
|
} else {
|
|
1715
1884
|
info += getDeclarationErrorAddendum();
|
|
1716
1885
|
}
|
|
1717
1886
|
|
|
1718
|
-
var typeString
|
|
1887
|
+
var typeString;
|
|
1888
|
+
|
|
1719
1889
|
if (type === null) {
|
|
1720
1890
|
typeString = 'null';
|
|
1721
1891
|
} else if (Array.isArray(type)) {
|
|
1722
1892
|
typeString = 'array';
|
|
1723
1893
|
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1724
|
-
typeString =
|
|
1894
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
1725
1895
|
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1726
1896
|
} else {
|
|
1727
1897
|
typeString = typeof type;
|
|
1728
1898
|
}
|
|
1729
1899
|
|
|
1730
|
-
|
|
1900
|
+
{
|
|
1901
|
+
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
1902
|
+
}
|
|
1731
1903
|
}
|
|
1732
1904
|
|
|
1733
|
-
var element =
|
|
1734
|
-
|
|
1735
|
-
// The result can be nullish if a mock or a custom function is used.
|
|
1905
|
+
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
1736
1906
|
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
1907
|
+
|
|
1737
1908
|
if (element == null) {
|
|
1738
1909
|
return element;
|
|
1910
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
1911
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
1912
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
1913
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
1914
|
+
// fixed, the key warnings will appear.)
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
if (validType) {
|
|
1918
|
+
var children = props.children;
|
|
1919
|
+
|
|
1920
|
+
if (children !== undefined) {
|
|
1921
|
+
if (isStaticChildren) {
|
|
1922
|
+
if (Array.isArray(children)) {
|
|
1923
|
+
for (var i = 0; i < children.length; i++) {
|
|
1924
|
+
validateChildKeys(children[i], type);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
if (Object.freeze) {
|
|
1928
|
+
Object.freeze(children);
|
|
1929
|
+
}
|
|
1930
|
+
} else {
|
|
1931
|
+
{
|
|
1932
|
+
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
} else {
|
|
1936
|
+
validateChildKeys(children, type);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
if (hasOwnProperty$1.call(props, 'key')) {
|
|
1942
|
+
{
|
|
1943
|
+
error('React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. <ComponentName {...props} key={key} />');
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
1948
|
+
validateFragmentProps(element);
|
|
1949
|
+
} else {
|
|
1950
|
+
validatePropTypes(element);
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
return element;
|
|
1954
|
+
} // These two functions exist to still get child warnings in dev
|
|
1955
|
+
// even with the prod transform. This means that jsxDEV is purely
|
|
1956
|
+
// opt-in behavior for better messages but that we won't stop
|
|
1957
|
+
// giving you warnings if you use production apis.
|
|
1958
|
+
|
|
1959
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
1960
|
+
return jsxWithValidation(type, props, key, true);
|
|
1961
|
+
}
|
|
1962
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
1963
|
+
return jsxWithValidation(type, props, key, false);
|
|
1964
|
+
}
|
|
1965
|
+
function createElementWithValidation(type, props, children) {
|
|
1966
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
1967
|
+
// succeed and there will likely be errors in render.
|
|
1968
|
+
|
|
1969
|
+
if (!validType) {
|
|
1970
|
+
var info = '';
|
|
1971
|
+
|
|
1972
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1973
|
+
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.";
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
var sourceInfo = getSourceInfoErrorAddendumForProps(props);
|
|
1977
|
+
|
|
1978
|
+
if (sourceInfo) {
|
|
1979
|
+
info += sourceInfo;
|
|
1980
|
+
} else {
|
|
1981
|
+
info += getDeclarationErrorAddendum();
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
var typeString;
|
|
1985
|
+
|
|
1986
|
+
if (type === null) {
|
|
1987
|
+
typeString = 'null';
|
|
1988
|
+
} else if (Array.isArray(type)) {
|
|
1989
|
+
typeString = 'array';
|
|
1990
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1991
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
1992
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1993
|
+
} else {
|
|
1994
|
+
typeString = typeof type;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
{
|
|
1998
|
+
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);
|
|
1999
|
+
}
|
|
1739
2000
|
}
|
|
1740
2001
|
|
|
1741
|
-
//
|
|
2002
|
+
var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
|
|
2003
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
2004
|
+
|
|
2005
|
+
if (element == null) {
|
|
2006
|
+
return element;
|
|
2007
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
1742
2008
|
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
1743
2009
|
// We don't want exception behavior to differ between dev and prod.
|
|
1744
2010
|
// (Rendering will throw with a helpful message and as soon as the type is
|
|
1745
2011
|
// fixed, the key warnings will appear.)
|
|
2012
|
+
|
|
2013
|
+
|
|
1746
2014
|
if (validType) {
|
|
1747
2015
|
for (var i = 2; i < arguments.length; i++) {
|
|
1748
2016
|
validateChildKeys(arguments[i], type);
|
|
@@ -1757,16 +2025,16 @@ function createElementWithValidation(type, props, children) {
|
|
|
1757
2025
|
|
|
1758
2026
|
return element;
|
|
1759
2027
|
}
|
|
1760
|
-
|
|
1761
2028
|
function createFactoryWithValidation(type) {
|
|
1762
2029
|
var validatedFactory = createElementWithValidation.bind(null, type);
|
|
1763
|
-
validatedFactory.type = type;
|
|
1764
|
-
|
|
2030
|
+
validatedFactory.type = type; // Legacy hook: remove it
|
|
2031
|
+
|
|
1765
2032
|
{
|
|
1766
2033
|
Object.defineProperty(validatedFactory, 'type', {
|
|
1767
2034
|
enumerable: false,
|
|
1768
2035
|
get: function () {
|
|
1769
|
-
|
|
2036
|
+
warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
|
|
2037
|
+
|
|
1770
2038
|
Object.defineProperty(this, 'type', {
|
|
1771
2039
|
value: type
|
|
1772
2040
|
});
|
|
@@ -1777,54 +2045,158 @@ function createFactoryWithValidation(type) {
|
|
|
1777
2045
|
|
|
1778
2046
|
return validatedFactory;
|
|
1779
2047
|
}
|
|
1780
|
-
|
|
1781
2048
|
function cloneElementWithValidation(element, props, children) {
|
|
1782
2049
|
var newElement = cloneElement.apply(this, arguments);
|
|
2050
|
+
|
|
1783
2051
|
for (var i = 2; i < arguments.length; i++) {
|
|
1784
2052
|
validateChildKeys(arguments[i], newElement.type);
|
|
1785
2053
|
}
|
|
2054
|
+
|
|
1786
2055
|
validatePropTypes(newElement);
|
|
1787
2056
|
return newElement;
|
|
1788
2057
|
}
|
|
1789
2058
|
|
|
1790
|
-
|
|
2059
|
+
var hasBadMapPolyfill;
|
|
1791
2060
|
|
|
2061
|
+
{
|
|
2062
|
+
hasBadMapPolyfill = false;
|
|
1792
2063
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
// This
|
|
2064
|
+
try {
|
|
2065
|
+
var frozenObject = Object.freeze({});
|
|
2066
|
+
var testMap = new Map([[frozenObject, null]]);
|
|
2067
|
+
var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused.
|
|
2068
|
+
// https://github.com/rollup/rollup/issues/1771
|
|
2069
|
+
// TODO: we can remove these if Rollup fixes the bug.
|
|
1797
2070
|
|
|
2071
|
+
testMap.set(0, 0);
|
|
2072
|
+
testSet.add(0);
|
|
2073
|
+
} catch (e) {
|
|
2074
|
+
// TODO: Consider warning about bad polyfills
|
|
2075
|
+
hasBadMapPolyfill = true;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
1798
2078
|
|
|
1799
|
-
|
|
1800
|
-
//
|
|
2079
|
+
function createFundamentalComponent(impl) {
|
|
2080
|
+
// We use responder as a Map key later on. When we have a bad
|
|
2081
|
+
// polyfill, then we can't use it as a key as the polyfill tries
|
|
2082
|
+
// to add a property to the object.
|
|
2083
|
+
if (true && !hasBadMapPolyfill) {
|
|
2084
|
+
Object.freeze(impl);
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
var fundamantalComponent = {
|
|
2088
|
+
$$typeof: REACT_FUNDAMENTAL_TYPE,
|
|
2089
|
+
impl: impl
|
|
2090
|
+
};
|
|
2091
|
+
|
|
2092
|
+
{
|
|
2093
|
+
Object.freeze(fundamantalComponent);
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
return fundamantalComponent;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
function createEventResponder(displayName, responderConfig) {
|
|
2100
|
+
var getInitialState = responderConfig.getInitialState,
|
|
2101
|
+
onEvent = responderConfig.onEvent,
|
|
2102
|
+
onMount = responderConfig.onMount,
|
|
2103
|
+
onUnmount = responderConfig.onUnmount,
|
|
2104
|
+
onRootEvent = responderConfig.onRootEvent,
|
|
2105
|
+
rootEventTypes = responderConfig.rootEventTypes,
|
|
2106
|
+
targetEventTypes = responderConfig.targetEventTypes,
|
|
2107
|
+
targetPortalPropagation = responderConfig.targetPortalPropagation;
|
|
2108
|
+
var eventResponder = {
|
|
2109
|
+
$$typeof: REACT_RESPONDER_TYPE,
|
|
2110
|
+
displayName: displayName,
|
|
2111
|
+
getInitialState: getInitialState || null,
|
|
2112
|
+
onEvent: onEvent || null,
|
|
2113
|
+
onMount: onMount || null,
|
|
2114
|
+
onRootEvent: onRootEvent || null,
|
|
2115
|
+
onUnmount: onUnmount || null,
|
|
2116
|
+
rootEventTypes: rootEventTypes || null,
|
|
2117
|
+
targetEventTypes: targetEventTypes || null,
|
|
2118
|
+
targetPortalPropagation: targetPortalPropagation || false
|
|
2119
|
+
}; // We use responder as a Map key later on. When we have a bad
|
|
2120
|
+
// polyfill, then we can't use it as a key as the polyfill tries
|
|
2121
|
+
// to add a property to the object.
|
|
2122
|
+
|
|
2123
|
+
if (true && !hasBadMapPolyfill) {
|
|
2124
|
+
Object.freeze(eventResponder);
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
return eventResponder;
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
function createScope() {
|
|
2131
|
+
var scopeComponent = {
|
|
2132
|
+
$$typeof: REACT_SCOPE_TYPE
|
|
2133
|
+
};
|
|
1801
2134
|
|
|
2135
|
+
{
|
|
2136
|
+
Object.freeze(scopeComponent);
|
|
2137
|
+
}
|
|
1802
2138
|
|
|
1803
|
-
|
|
2139
|
+
return scopeComponent;
|
|
2140
|
+
}
|
|
1804
2141
|
|
|
2142
|
+
// Helps identify side effects in render-phase lifecycle hooks and setState
|
|
2143
|
+
// reducers by double invoking them in Strict Mode.
|
|
1805
2144
|
|
|
1806
|
-
//
|
|
2145
|
+
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
2146
|
+
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
1807
2147
|
|
|
2148
|
+
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
1808
2149
|
|
|
1809
|
-
//
|
|
2150
|
+
// Gather advanced timing metrics for Profiler subtrees.
|
|
1810
2151
|
|
|
2152
|
+
// Trace which interactions trigger each commit.
|
|
1811
2153
|
|
|
1812
|
-
//
|
|
1813
|
-
// TODO: true? Here it might just be false.
|
|
2154
|
+
// SSR experiments
|
|
1814
2155
|
|
|
1815
|
-
// Only used in www builds.
|
|
1816
2156
|
|
|
2157
|
+
// Only used in www builds.
|
|
1817
2158
|
|
|
1818
|
-
// Only used in www builds.
|
|
2159
|
+
// Only used in www builds.
|
|
1819
2160
|
|
|
2161
|
+
// Disable javascript: URL strings in href for XSS protection.
|
|
1820
2162
|
|
|
1821
|
-
// React Fire: prevent the value and checked attributes from syncing
|
|
2163
|
+
// React Fire: prevent the value and checked attributes from syncing
|
|
1822
2164
|
// with their related DOM properties
|
|
1823
2165
|
|
|
1824
|
-
|
|
1825
|
-
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
|
|
2166
|
+
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
|
|
1826
2167
|
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
|
|
1827
|
-
|
|
2168
|
+
|
|
2169
|
+
var exposeConcurrentModeAPIs = false;
|
|
2170
|
+
// Experimental React Flare event system and event components support.
|
|
2171
|
+
|
|
2172
|
+
var enableFlareAPI = false; // Experimental Host Component support.
|
|
2173
|
+
|
|
2174
|
+
var enableFundamentalAPI = false; // Experimental Scope support.
|
|
2175
|
+
|
|
2176
|
+
var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
|
2177
|
+
|
|
2178
|
+
var enableJSXTransformAPI = false; // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
|
|
2179
|
+
// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version
|
|
2180
|
+
|
|
2181
|
+
// For tests, we flush suspense fallbacks in an act scope;
|
|
2182
|
+
// *except* in some of our own tests, where we test incremental loading states.
|
|
2183
|
+
|
|
2184
|
+
// Add a callback property to suspense to notify which promises are currently
|
|
2185
|
+
// in the update queue. This allows reporting and tracing of what is causing
|
|
2186
|
+
// the user to see a loading state.
|
|
2187
|
+
// Also allows hydration callbacks to fire when a dehydrated boundary gets
|
|
2188
|
+
// hydrated or deleted.
|
|
2189
|
+
|
|
2190
|
+
// Part of the simplification of React.createElement so we can eventually move
|
|
2191
|
+
// from React.createElement to React.jsx
|
|
2192
|
+
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
|
|
2199
|
+
// Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance
|
|
1828
2200
|
|
|
1829
2201
|
var React = {
|
|
1830
2202
|
Children: {
|
|
@@ -1834,16 +2206,13 @@ var React = {
|
|
|
1834
2206
|
toArray: toArray,
|
|
1835
2207
|
only: onlyChild
|
|
1836
2208
|
},
|
|
1837
|
-
|
|
1838
2209
|
createRef: createRef,
|
|
1839
2210
|
Component: Component,
|
|
1840
2211
|
PureComponent: PureComponent,
|
|
1841
|
-
|
|
1842
2212
|
createContext: createContext,
|
|
1843
2213
|
forwardRef: forwardRef,
|
|
1844
2214
|
lazy: lazy,
|
|
1845
2215
|
memo: memo,
|
|
1846
|
-
|
|
1847
2216
|
useCallback: useCallback,
|
|
1848
2217
|
useContext: useContext,
|
|
1849
2218
|
useEffect: useEffect,
|
|
@@ -1854,34 +2223,48 @@ var React = {
|
|
|
1854
2223
|
useReducer: useReducer,
|
|
1855
2224
|
useRef: useRef,
|
|
1856
2225
|
useState: useState,
|
|
1857
|
-
|
|
1858
2226
|
Fragment: REACT_FRAGMENT_TYPE,
|
|
2227
|
+
Profiler: REACT_PROFILER_TYPE,
|
|
1859
2228
|
StrictMode: REACT_STRICT_MODE_TYPE,
|
|
1860
2229
|
Suspense: REACT_SUSPENSE_TYPE,
|
|
1861
|
-
|
|
1862
2230
|
createElement: createElementWithValidation,
|
|
1863
2231
|
cloneElement: cloneElementWithValidation,
|
|
1864
2232
|
createFactory: createFactoryWithValidation,
|
|
1865
2233
|
isValidElement: isValidElement,
|
|
1866
|
-
|
|
1867
2234
|
version: ReactVersion,
|
|
1868
|
-
|
|
1869
|
-
unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
|
|
1870
|
-
unstable_Profiler: REACT_PROFILER_TYPE,
|
|
1871
|
-
|
|
1872
2235
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
|
|
1873
2236
|
};
|
|
1874
2237
|
|
|
1875
|
-
|
|
2238
|
+
if (exposeConcurrentModeAPIs) {
|
|
2239
|
+
React.useTransition = useTransition;
|
|
2240
|
+
React.useDeferredValue = useDeferredValue;
|
|
2241
|
+
React.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
2242
|
+
React.unstable_withSuspenseConfig = withSuspenseConfig;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
if (enableFlareAPI) {
|
|
2246
|
+
React.unstable_useResponder = useResponder;
|
|
2247
|
+
React.unstable_createResponder = createEventResponder;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
if (enableFundamentalAPI) {
|
|
2251
|
+
React.unstable_createFundamental = createFundamentalComponent;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
if (enableScopeAPI) {
|
|
2255
|
+
React.unstable_createScope = createScope;
|
|
2256
|
+
} // Note: some APIs are added with feature flags.
|
|
1876
2257
|
// Make sure that stable builds for open source
|
|
1877
2258
|
// don't modify the React object to avoid deopts.
|
|
1878
2259
|
// Also let's not expose their names in stable builds.
|
|
1879
2260
|
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
2261
|
+
|
|
2262
|
+
if (enableJSXTransformAPI) {
|
|
2263
|
+
{
|
|
2264
|
+
React.jsxDEV = jsxWithValidation;
|
|
2265
|
+
React.jsx = jsxWithValidationDynamic;
|
|
2266
|
+
React.jsxs = jsxWithValidationStatic;
|
|
2267
|
+
}
|
|
1885
2268
|
}
|
|
1886
2269
|
|
|
1887
2270
|
|
|
@@ -1894,6 +2277,8 @@ var React$3 = ( React$2 && React ) || React$2;
|
|
|
1894
2277
|
|
|
1895
2278
|
// TODO: decide on the top-level export form.
|
|
1896
2279
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
2280
|
+
|
|
2281
|
+
|
|
1897
2282
|
var react = React$3.default || React$3;
|
|
1898
2283
|
|
|
1899
2284
|
module.exports = react;
|