react 18.3.0 → 19.0.0-beta-94eed63c49-20240425
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/LICENSE +1 -1
- package/README.md +3 -3
- package/cjs/react-jsx-dev-runtime.development.js +599 -631
- package/cjs/react-jsx-dev-runtime.production.js +14 -0
- package/cjs/react-jsx-dev-runtime.profiling.js +14 -0
- package/cjs/react-jsx-runtime.development.js +623 -645
- package/cjs/react-jsx-runtime.production.js +34 -0
- package/cjs/react-jsx-runtime.profiling.js +34 -0
- package/cjs/react-jsx-runtime.react-server.development.js +1318 -0
- package/cjs/react-jsx-runtime.react-server.production.js +40 -0
- package/cjs/react.development.js +1781 -1703
- package/cjs/react.production.js +539 -0
- package/cjs/react.react-server.development.js +2194 -0
- package/cjs/react.react-server.production.js +479 -0
- package/index.js +1 -1
- package/jsx-dev-runtime.js +1 -1
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.react-server.js +7 -0
- package/package.json +9 -14
- package/react.react-server.js +7 -0
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -10
- package/cjs/react-jsx-dev-runtime.profiling.min.js +0 -10
- package/cjs/react-jsx-runtime.production.min.js +0 -11
- package/cjs/react-jsx-runtime.profiling.min.js +0 -11
- package/cjs/react.production.min.js +0 -26
- package/cjs/react.shared-subset.development.js +0 -20
- package/cjs/react.shared-subset.production.min.js +0 -10
- package/react.shared-subset.js +0 -7
- package/umd/react.development.js +0 -3342
- package/umd/react.production.min.js +0 -31
- package/umd/react.profiling.min.js +0 -31
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-dev-runtime.development.js
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -16,16 +16,32 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
16
16
|
|
|
17
17
|
var React = require('react');
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
19
|
+
// -----------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
22
|
+
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
23
|
+
|
|
24
|
+
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
25
|
+
// as a normal prop instead of stripping it from the props object.
|
|
26
|
+
// Passes `ref` as a normal prop instead of stripping it from the props object
|
|
27
|
+
// during element creation.
|
|
28
|
+
|
|
29
|
+
var enableRefAsProp = true;
|
|
30
|
+
|
|
31
|
+
var enableRenderableContext = true; // Enables the `initialValue` option for `useDeferredValue`
|
|
32
|
+
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
33
|
+
// issues in DEV builds.
|
|
34
|
+
|
|
35
|
+
var enableDebugTracing = false;
|
|
36
|
+
|
|
37
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element') ;
|
|
24
38
|
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
25
39
|
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
26
40
|
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
27
41
|
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
28
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
42
|
+
var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); // TODO: Delete with enableRenderableContext
|
|
43
|
+
|
|
44
|
+
var REACT_CONSUMER_TYPE = Symbol.for('react.consumer');
|
|
29
45
|
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
30
46
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
31
47
|
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
@@ -49,7 +65,7 @@ function getIteratorFn(maybeIterable) {
|
|
|
49
65
|
return null;
|
|
50
66
|
}
|
|
51
67
|
|
|
52
|
-
var ReactSharedInternals = React.
|
|
68
|
+
var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
53
69
|
|
|
54
70
|
function error(format) {
|
|
55
71
|
{
|
|
@@ -67,8 +83,7 @@ function printWarning(level, format, args) {
|
|
|
67
83
|
// When changing this logic, you might want to also
|
|
68
84
|
// update consoleWithStackDev.www.js as well.
|
|
69
85
|
{
|
|
70
|
-
var
|
|
71
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
86
|
+
var stack = ReactSharedInternals.getStackAddendum();
|
|
72
87
|
|
|
73
88
|
if (stack !== '') {
|
|
74
89
|
format += '%s';
|
|
@@ -88,47 +103,6 @@ function printWarning(level, format, args) {
|
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
105
|
|
|
91
|
-
// -----------------------------------------------------------------------------
|
|
92
|
-
|
|
93
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
94
|
-
var enableCacheElement = false;
|
|
95
|
-
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
96
|
-
|
|
97
|
-
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
98
|
-
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
99
|
-
// issues in DEV builds.
|
|
100
|
-
|
|
101
|
-
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
102
|
-
|
|
103
|
-
var REACT_MODULE_REFERENCE;
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function isValidElementType(type) {
|
|
110
|
-
if (typeof type === 'string' || typeof type === 'function') {
|
|
111
|
-
return true;
|
|
112
|
-
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (typeof type === 'object' && type !== null) {
|
|
120
|
-
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
121
|
-
// types supported by any Flight configuration anywhere since
|
|
122
|
-
// we don't know which Flight build this will end up being used
|
|
123
|
-
// with.
|
|
124
|
-
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
106
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
133
107
|
var displayName = outerType.displayName;
|
|
134
108
|
|
|
@@ -143,8 +117,9 @@ function getWrappedName(outerType, innerType, wrapperName) {
|
|
|
143
117
|
|
|
144
118
|
function getContextName(type) {
|
|
145
119
|
return type.displayName || 'Context';
|
|
146
|
-
}
|
|
120
|
+
}
|
|
147
121
|
|
|
122
|
+
var REACT_CLIENT_REFERENCE$2 = Symbol.for('react.client.reference'); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
|
|
148
123
|
|
|
149
124
|
function getComponentNameFromType(type) {
|
|
150
125
|
if (type == null) {
|
|
@@ -152,13 +127,12 @@ function getComponentNameFromType(type) {
|
|
|
152
127
|
return null;
|
|
153
128
|
}
|
|
154
129
|
|
|
155
|
-
{
|
|
156
|
-
if (typeof
|
|
157
|
-
|
|
130
|
+
if (typeof type === 'function') {
|
|
131
|
+
if (type.$$typeof === REACT_CLIENT_REFERENCE$2) {
|
|
132
|
+
// TODO: Create a convention for naming client references with debug info.
|
|
133
|
+
return null;
|
|
158
134
|
}
|
|
159
|
-
}
|
|
160
135
|
|
|
161
|
-
if (typeof type === 'function') {
|
|
162
136
|
return type.displayName || type.name || null;
|
|
163
137
|
}
|
|
164
138
|
|
|
@@ -188,14 +162,30 @@ function getComponentNameFromType(type) {
|
|
|
188
162
|
}
|
|
189
163
|
|
|
190
164
|
if (typeof type === 'object') {
|
|
165
|
+
{
|
|
166
|
+
if (typeof type.tag === 'number') {
|
|
167
|
+
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
191
171
|
switch (type.$$typeof) {
|
|
172
|
+
case REACT_PROVIDER_TYPE:
|
|
173
|
+
{
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
192
177
|
case REACT_CONTEXT_TYPE:
|
|
193
178
|
var context = type;
|
|
194
|
-
return getContextName(context) + '.Consumer';
|
|
195
179
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
180
|
+
{
|
|
181
|
+
return getContextName(context) + '.Provider';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
case REACT_CONSUMER_TYPE:
|
|
185
|
+
{
|
|
186
|
+
var consumer = type;
|
|
187
|
+
return getContextName(consumer._context) + '.Consumer';
|
|
188
|
+
}
|
|
199
189
|
|
|
200
190
|
case REACT_FORWARD_REF_TYPE:
|
|
201
191
|
return getWrappedName(type, type.render, 'ForwardRef');
|
|
@@ -221,16 +211,115 @@ function getComponentNameFromType(type) {
|
|
|
221
211
|
return null;
|
|
222
212
|
}
|
|
223
213
|
}
|
|
224
|
-
|
|
225
|
-
// eslint-disable-next-line no-fallthrough
|
|
226
214
|
}
|
|
227
215
|
}
|
|
228
216
|
|
|
229
217
|
return null;
|
|
230
218
|
}
|
|
231
219
|
|
|
220
|
+
// $FlowFixMe[method-unbinding]
|
|
221
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
222
|
+
|
|
232
223
|
var assign = Object.assign;
|
|
233
224
|
|
|
225
|
+
/*
|
|
226
|
+
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
|
|
227
|
+
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
|
228
|
+
*
|
|
229
|
+
* The functions in this module will throw an easier-to-understand,
|
|
230
|
+
* easier-to-debug exception with a clear errors message message explaining the
|
|
231
|
+
* problem. (Instead of a confusing exception thrown inside the implementation
|
|
232
|
+
* of the `value` object).
|
|
233
|
+
*/
|
|
234
|
+
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
|
|
235
|
+
function typeName(value) {
|
|
236
|
+
{
|
|
237
|
+
// toStringTag is needed for namespaced types like Temporal.Instant
|
|
238
|
+
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
|
239
|
+
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; // $FlowFixMe[incompatible-return]
|
|
240
|
+
|
|
241
|
+
return type;
|
|
242
|
+
}
|
|
243
|
+
} // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
function willCoercionThrow(value) {
|
|
247
|
+
{
|
|
248
|
+
try {
|
|
249
|
+
testStringCoercion(value);
|
|
250
|
+
return false;
|
|
251
|
+
} catch (e) {
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function testStringCoercion(value) {
|
|
258
|
+
// If you ended up here by following an exception call stack, here's what's
|
|
259
|
+
// happened: you supplied an object or symbol value to React (as a prop, key,
|
|
260
|
+
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
|
261
|
+
// coerce it to a string using `'' + value`, an exception was thrown.
|
|
262
|
+
//
|
|
263
|
+
// The most common types that will cause this exception are `Symbol` instances
|
|
264
|
+
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
|
265
|
+
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
|
266
|
+
// exception. (Library authors do this to prevent users from using built-in
|
|
267
|
+
// numeric operators like `+` or comparison operators like `>=` because custom
|
|
268
|
+
// methods are needed to perform accurate arithmetic or comparison.)
|
|
269
|
+
//
|
|
270
|
+
// To fix the problem, coerce this object or symbol value to a string before
|
|
271
|
+
// passing it to React. The most reliable way is usually `String(value)`.
|
|
272
|
+
//
|
|
273
|
+
// To find which value is throwing, check the browser or debugger console.
|
|
274
|
+
// Before this exception was thrown, there should be `console.error` output
|
|
275
|
+
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
|
276
|
+
// problem and how that type was used: key, atrribute, input value prop, etc.
|
|
277
|
+
// In most cases, this console output also shows the component and its
|
|
278
|
+
// ancestor components where the exception happened.
|
|
279
|
+
//
|
|
280
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
281
|
+
return '' + value;
|
|
282
|
+
}
|
|
283
|
+
function checkKeyStringCoercion(value) {
|
|
284
|
+
{
|
|
285
|
+
if (willCoercionThrow(value)) {
|
|
286
|
+
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before using it here.', typeName(value));
|
|
287
|
+
|
|
288
|
+
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
|
|
294
|
+
function isValidElementType(type) {
|
|
295
|
+
if (typeof type === 'string' || typeof type === 'function') {
|
|
296
|
+
return true;
|
|
297
|
+
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableTransitionTracing ) {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (typeof type === 'object' && type !== null) {
|
|
305
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || !enableRenderableContext || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
306
|
+
// types supported by any Flight configuration anywhere since
|
|
307
|
+
// we don't know which Flight build this will end up being used
|
|
308
|
+
// with.
|
|
309
|
+
type.$$typeof === REACT_CLIENT_REFERENCE$1 || type.getModuleId !== undefined) {
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
318
|
+
|
|
319
|
+
function isArray(a) {
|
|
320
|
+
return isArrayImpl(a);
|
|
321
|
+
}
|
|
322
|
+
|
|
234
323
|
// Helpers to patch console.logs to avoid logging during side-effect free
|
|
235
324
|
// replaying on render function. This currently only patches the object
|
|
236
325
|
// lazily which won't cover if the log function was extracted eagerly.
|
|
@@ -264,7 +353,7 @@ function disableLogs() {
|
|
|
264
353
|
enumerable: true,
|
|
265
354
|
value: disabledLog,
|
|
266
355
|
writable: true
|
|
267
|
-
}; // $FlowFixMe Flow thinks console is immutable.
|
|
356
|
+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
|
|
268
357
|
|
|
269
358
|
Object.defineProperties(console, {
|
|
270
359
|
info: props,
|
|
@@ -291,7 +380,7 @@ function reenableLogs() {
|
|
|
291
380
|
configurable: true,
|
|
292
381
|
enumerable: true,
|
|
293
382
|
writable: true
|
|
294
|
-
}; // $FlowFixMe Flow thinks console is immutable.
|
|
383
|
+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
|
|
295
384
|
|
|
296
385
|
Object.defineProperties(console, {
|
|
297
386
|
log: assign({}, props, {
|
|
@@ -325,9 +414,8 @@ function reenableLogs() {
|
|
|
325
414
|
}
|
|
326
415
|
}
|
|
327
416
|
|
|
328
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
329
417
|
var prefix;
|
|
330
|
-
function describeBuiltInComponentFrame(name
|
|
418
|
+
function describeBuiltInComponentFrame(name) {
|
|
331
419
|
{
|
|
332
420
|
if (prefix === undefined) {
|
|
333
421
|
// Extract the VM specific prefix used by each line.
|
|
@@ -350,10 +438,22 @@ var componentFrameCache;
|
|
|
350
438
|
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
351
439
|
componentFrameCache = new PossiblyWeakMap();
|
|
352
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Leverages native browser/VM stack frames to get proper details (e.g.
|
|
443
|
+
* filename, line + col number) for a single component in a component stack. We
|
|
444
|
+
* do this by:
|
|
445
|
+
* (1) throwing and catching an error in the function - this will be our
|
|
446
|
+
* control error.
|
|
447
|
+
* (2) calling the component which will eventually throw an error that we'll
|
|
448
|
+
* catch - this will be our sample error.
|
|
449
|
+
* (3) diffing the control and sample error stacks to find the stack frame
|
|
450
|
+
* which represents our component.
|
|
451
|
+
*/
|
|
452
|
+
|
|
353
453
|
|
|
354
454
|
function describeNativeComponentFrame(fn, construct) {
|
|
355
455
|
// If something asked for a stack inside a fake render, it should get ignored.
|
|
356
|
-
if (
|
|
456
|
+
if (!fn || reentry) {
|
|
357
457
|
return '';
|
|
358
458
|
}
|
|
359
459
|
|
|
@@ -365,84 +465,153 @@ function describeNativeComponentFrame(fn, construct) {
|
|
|
365
465
|
}
|
|
366
466
|
}
|
|
367
467
|
|
|
368
|
-
var control;
|
|
369
468
|
reentry = true;
|
|
370
|
-
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
|
|
469
|
+
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined.
|
|
371
470
|
|
|
372
471
|
Error.prepareStackTrace = undefined;
|
|
373
|
-
var previousDispatcher;
|
|
472
|
+
var previousDispatcher = null;
|
|
374
473
|
|
|
375
474
|
{
|
|
376
|
-
previousDispatcher =
|
|
475
|
+
previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function
|
|
377
476
|
// for warnings.
|
|
378
477
|
|
|
379
|
-
|
|
478
|
+
ReactSharedInternals.H = null;
|
|
380
479
|
disableLogs();
|
|
381
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* Finding a common stack frame between sample and control errors can be
|
|
483
|
+
* tricky given the different types and levels of stack trace truncation from
|
|
484
|
+
* different JS VMs. So instead we'll attempt to control what that common
|
|
485
|
+
* frame should be through this object method:
|
|
486
|
+
* Having both the sample and control errors be in the function under the
|
|
487
|
+
* `DescribeNativeComponentFrameRoot` property, + setting the `name` and
|
|
488
|
+
* `displayName` properties of the function ensures that a stack
|
|
489
|
+
* frame exists that has the method name `DescribeNativeComponentFrameRoot` in
|
|
490
|
+
* it for both control and sample stacks.
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
var RunInRootFrame = {
|
|
495
|
+
DetermineComponentFrameRoot: function () {
|
|
496
|
+
var control;
|
|
382
497
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
498
|
+
try {
|
|
499
|
+
// This should throw.
|
|
500
|
+
if (construct) {
|
|
501
|
+
// Something should be setting the props in the constructor.
|
|
502
|
+
var Fake = function () {
|
|
503
|
+
throw Error();
|
|
504
|
+
}; // $FlowFixMe[prop-missing]
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
Object.defineProperty(Fake.prototype, 'props', {
|
|
508
|
+
set: function () {
|
|
509
|
+
// We use a throwing setter instead of frozen or non-writable props
|
|
510
|
+
// because that won't throw in a non-strict mode function.
|
|
511
|
+
throw Error();
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
if (typeof Reflect === 'object' && Reflect.construct) {
|
|
516
|
+
// We construct a different control for this case to include any extra
|
|
517
|
+
// frames added by the construct call.
|
|
518
|
+
try {
|
|
519
|
+
Reflect.construct(Fake, []);
|
|
520
|
+
} catch (x) {
|
|
521
|
+
control = x;
|
|
522
|
+
}
|
|
390
523
|
|
|
524
|
+
Reflect.construct(fn, [], Fake);
|
|
525
|
+
} else {
|
|
526
|
+
try {
|
|
527
|
+
Fake.call();
|
|
528
|
+
} catch (x) {
|
|
529
|
+
control = x;
|
|
530
|
+
} // $FlowFixMe[prop-missing] found when upgrading Flow
|
|
391
531
|
|
|
392
|
-
Object.defineProperty(Fake.prototype, 'props', {
|
|
393
|
-
set: function () {
|
|
394
|
-
// We use a throwing setter instead of frozen or non-writable props
|
|
395
|
-
// because that won't throw in a non-strict mode function.
|
|
396
|
-
throw Error();
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
532
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
533
|
+
fn.call(Fake.prototype);
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
try {
|
|
537
|
+
throw Error();
|
|
538
|
+
} catch (x) {
|
|
539
|
+
control = x;
|
|
540
|
+
} // TODO(luna): This will currently only throw if the function component
|
|
541
|
+
// tries to access React/ReactDOM/props. We should probably make this throw
|
|
542
|
+
// in simple components too
|
|
408
543
|
|
|
409
|
-
Reflect.construct(fn, [], Fake);
|
|
410
|
-
} else {
|
|
411
|
-
try {
|
|
412
|
-
Fake.call();
|
|
413
|
-
} catch (x) {
|
|
414
|
-
control = x;
|
|
415
|
-
}
|
|
416
544
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
545
|
+
var maybePromise = fn(); // If the function component returns a promise, it's likely an async
|
|
546
|
+
// component, which we don't yet support. Attach a noop catch handler to
|
|
547
|
+
// silence the error.
|
|
548
|
+
// TODO: Implement component stacks for async client components?
|
|
549
|
+
|
|
550
|
+
if (maybePromise && typeof maybePromise.catch === 'function') {
|
|
551
|
+
maybePromise.catch(function () {});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
} catch (sample) {
|
|
555
|
+
// This is inlined manually because closure doesn't do it for us.
|
|
556
|
+
if (sample && control && typeof sample.stack === 'string') {
|
|
557
|
+
return [sample.stack, control.stack];
|
|
558
|
+
}
|
|
424
559
|
}
|
|
425
560
|
|
|
426
|
-
|
|
561
|
+
return [null, null];
|
|
427
562
|
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
|
|
563
|
+
}; // $FlowFixMe[prop-missing]
|
|
564
|
+
|
|
565
|
+
RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot';
|
|
566
|
+
var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable.
|
|
567
|
+
|
|
568
|
+
if (namePropDescriptor && namePropDescriptor.configurable) {
|
|
569
|
+
// V8 utilizes a function's `name` property when generating a stack trace.
|
|
570
|
+
Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor
|
|
571
|
+
// is set to `false`.
|
|
572
|
+
// $FlowFixMe[cannot-write]
|
|
573
|
+
'name', {
|
|
574
|
+
value: 'DetermineComponentFrameRoot'
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
try {
|
|
579
|
+
var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(),
|
|
580
|
+
sampleStack = _RunInRootFrame$Deter[0],
|
|
581
|
+
controlStack = _RunInRootFrame$Deter[1];
|
|
582
|
+
|
|
583
|
+
if (sampleStack && controlStack) {
|
|
431
584
|
// This extracts the first frame from the sample that isn't also in the control.
|
|
432
585
|
// Skipping one frame that we assume is the frame that calls the two.
|
|
433
|
-
var sampleLines =
|
|
434
|
-
var controlLines =
|
|
435
|
-
var s =
|
|
436
|
-
var c =
|
|
437
|
-
|
|
438
|
-
while (s
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
586
|
+
var sampleLines = sampleStack.split('\n');
|
|
587
|
+
var controlLines = controlStack.split('\n');
|
|
588
|
+
var s = 0;
|
|
589
|
+
var c = 0;
|
|
590
|
+
|
|
591
|
+
while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) {
|
|
592
|
+
s++;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) {
|
|
596
|
+
c++;
|
|
597
|
+
} // We couldn't find our intentionally injected common root frame, attempt
|
|
598
|
+
// to find another common root frame by search from the bottom of the
|
|
599
|
+
// control stack...
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
if (s === sampleLines.length || c === controlLines.length) {
|
|
603
|
+
s = sampleLines.length - 1;
|
|
604
|
+
c = controlLines.length - 1;
|
|
605
|
+
|
|
606
|
+
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
607
|
+
// We expect at least one stack frame to be shared.
|
|
608
|
+
// Typically this will be the root most one. However, stack frames may be
|
|
609
|
+
// cut off due to maximum stack limits. In this case, one maybe cut off
|
|
610
|
+
// earlier than the other. We assume that the sample is longer or the same
|
|
611
|
+
// and there for cut off earlier. So we should find the root most frame in
|
|
612
|
+
// the sample somewhere in the control.
|
|
613
|
+
c--;
|
|
614
|
+
}
|
|
446
615
|
}
|
|
447
616
|
|
|
448
617
|
for (; s >= 1 && c >= 0; s--, c--) {
|
|
@@ -471,7 +640,7 @@ function describeNativeComponentFrame(fn, construct) {
|
|
|
471
640
|
_frame = _frame.replace('<anonymous>', fn.displayName);
|
|
472
641
|
}
|
|
473
642
|
|
|
474
|
-
{
|
|
643
|
+
if (true) {
|
|
475
644
|
if (typeof fn === 'function') {
|
|
476
645
|
componentFrameCache.set(fn, _frame);
|
|
477
646
|
}
|
|
@@ -491,7 +660,7 @@ function describeNativeComponentFrame(fn, construct) {
|
|
|
491
660
|
reentry = false;
|
|
492
661
|
|
|
493
662
|
{
|
|
494
|
-
|
|
663
|
+
ReactSharedInternals.H = previousDispatcher;
|
|
495
664
|
reenableLogs();
|
|
496
665
|
}
|
|
497
666
|
|
|
@@ -510,7 +679,7 @@ function describeNativeComponentFrame(fn, construct) {
|
|
|
510
679
|
|
|
511
680
|
return syntheticFrame;
|
|
512
681
|
}
|
|
513
|
-
function describeFunctionComponentFrame(fn
|
|
682
|
+
function describeFunctionComponentFrame(fn) {
|
|
514
683
|
{
|
|
515
684
|
return describeNativeComponentFrame(fn, false);
|
|
516
685
|
}
|
|
@@ -521,7 +690,7 @@ function shouldConstruct(Component) {
|
|
|
521
690
|
return !!(prototype && prototype.isReactComponent);
|
|
522
691
|
}
|
|
523
692
|
|
|
524
|
-
function describeUnknownElementTypeFrameInDEV(type
|
|
693
|
+
function describeUnknownElementTypeFrameInDEV(type) {
|
|
525
694
|
|
|
526
695
|
if (type == null) {
|
|
527
696
|
return '';
|
|
@@ -552,7 +721,7 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
|
552
721
|
|
|
553
722
|
case REACT_MEMO_TYPE:
|
|
554
723
|
// Memo may contain any component type so we recursively resolve it.
|
|
555
|
-
return describeUnknownElementTypeFrameInDEV(type.type
|
|
724
|
+
return describeUnknownElementTypeFrameInDEV(type.type);
|
|
556
725
|
|
|
557
726
|
case REACT_LAZY_TYPE:
|
|
558
727
|
{
|
|
@@ -562,7 +731,7 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
|
562
731
|
|
|
563
732
|
try {
|
|
564
733
|
// Lazy may contain any component type so we recursively resolve it.
|
|
565
|
-
return describeUnknownElementTypeFrameInDEV(init(payload)
|
|
734
|
+
return describeUnknownElementTypeFrameInDEV(init(payload));
|
|
566
735
|
} catch (x) {}
|
|
567
736
|
}
|
|
568
737
|
}
|
|
@@ -571,200 +740,53 @@ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
|
571
740
|
return '';
|
|
572
741
|
}
|
|
573
742
|
|
|
574
|
-
var
|
|
575
|
-
|
|
576
|
-
var loggedTypeFailures = {};
|
|
577
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
743
|
+
var REACT_CLIENT_REFERENCE = Symbol.for('react.client.reference');
|
|
578
744
|
|
|
579
|
-
function
|
|
745
|
+
function getOwner() {
|
|
580
746
|
{
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
} else {
|
|
586
|
-
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
747
|
+
var dispatcher = ReactSharedInternals.A;
|
|
748
|
+
|
|
749
|
+
if (dispatcher === null) {
|
|
750
|
+
return null;
|
|
587
751
|
}
|
|
752
|
+
|
|
753
|
+
return dispatcher.getOwner();
|
|
588
754
|
}
|
|
589
755
|
}
|
|
590
756
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
594
|
-
var has = Function.call.bind(hasOwnProperty);
|
|
595
|
-
|
|
596
|
-
for (var typeSpecName in typeSpecs) {
|
|
597
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
598
|
-
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
599
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
600
|
-
// After these have been cleaned up, we'll let them throw.
|
|
601
|
-
|
|
602
|
-
try {
|
|
603
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
604
|
-
// behavior as without this statement except with a better message.
|
|
605
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
606
|
-
// eslint-disable-next-line react-internal/prod-error-codes
|
|
607
|
-
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
608
|
-
err.name = 'Invariant Violation';
|
|
609
|
-
throw err;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
613
|
-
} catch (ex) {
|
|
614
|
-
error$1 = ex;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (error$1 && !(error$1 instanceof Error)) {
|
|
618
|
-
setCurrentlyValidatingElement(element);
|
|
619
|
-
|
|
620
|
-
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
621
|
-
|
|
622
|
-
setCurrentlyValidatingElement(null);
|
|
623
|
-
}
|
|
757
|
+
var specialPropKeyWarningShown;
|
|
758
|
+
var didWarnAboutElementRef;
|
|
624
759
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
loggedTypeFailures[error$1.message] = true;
|
|
629
|
-
setCurrentlyValidatingElement(element);
|
|
760
|
+
{
|
|
761
|
+
didWarnAboutElementRef = {};
|
|
762
|
+
}
|
|
630
763
|
|
|
631
|
-
|
|
764
|
+
function hasValidRef(config) {
|
|
765
|
+
{
|
|
766
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
767
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
632
768
|
|
|
633
|
-
|
|
634
|
-
|
|
769
|
+
if (getter && getter.isReactWarning) {
|
|
770
|
+
return false;
|
|
635
771
|
}
|
|
636
772
|
}
|
|
637
773
|
}
|
|
638
|
-
}
|
|
639
774
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
function isArray(a) {
|
|
643
|
-
return isArrayImpl(a);
|
|
775
|
+
return config.ref !== undefined;
|
|
644
776
|
}
|
|
645
777
|
|
|
646
|
-
|
|
647
|
-
* The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
|
|
648
|
-
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
|
649
|
-
*
|
|
650
|
-
* The functions in this module will throw an easier-to-understand,
|
|
651
|
-
* easier-to-debug exception with a clear errors message message explaining the
|
|
652
|
-
* problem. (Instead of a confusing exception thrown inside the implementation
|
|
653
|
-
* of the `value` object).
|
|
654
|
-
*/
|
|
655
|
-
// $FlowFixMe only called in DEV, so void return is not possible.
|
|
656
|
-
function typeName(value) {
|
|
778
|
+
function hasValidKey(config) {
|
|
657
779
|
{
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
|
|
661
|
-
return type;
|
|
662
|
-
}
|
|
663
|
-
} // $FlowFixMe only called in DEV, so void return is not possible.
|
|
664
|
-
|
|
780
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
781
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
665
782
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
testStringCoercion(value);
|
|
670
|
-
return false;
|
|
671
|
-
} catch (e) {
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
function testStringCoercion(value) {
|
|
678
|
-
// If you ended up here by following an exception call stack, here's what's
|
|
679
|
-
// happened: you supplied an object or symbol value to React (as a prop, key,
|
|
680
|
-
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
|
681
|
-
// coerce it to a string using `'' + value`, an exception was thrown.
|
|
682
|
-
//
|
|
683
|
-
// The most common types that will cause this exception are `Symbol` instances
|
|
684
|
-
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
|
685
|
-
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
|
686
|
-
// exception. (Library authors do this to prevent users from using built-in
|
|
687
|
-
// numeric operators like `+` or comparison operators like `>=` because custom
|
|
688
|
-
// methods are needed to perform accurate arithmetic or comparison.)
|
|
689
|
-
//
|
|
690
|
-
// To fix the problem, coerce this object or symbol value to a string before
|
|
691
|
-
// passing it to React. The most reliable way is usually `String(value)`.
|
|
692
|
-
//
|
|
693
|
-
// To find which value is throwing, check the browser or debugger console.
|
|
694
|
-
// Before this exception was thrown, there should be `console.error` output
|
|
695
|
-
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
|
696
|
-
// problem and how that type was used: key, atrribute, input value prop, etc.
|
|
697
|
-
// In most cases, this console output also shows the component and its
|
|
698
|
-
// ancestor components where the exception happened.
|
|
699
|
-
//
|
|
700
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
701
|
-
return '' + value;
|
|
702
|
-
}
|
|
703
|
-
function checkKeyStringCoercion(value) {
|
|
704
|
-
{
|
|
705
|
-
if (willCoercionThrow(value)) {
|
|
706
|
-
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
|
|
707
|
-
|
|
708
|
-
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
714
|
-
var RESERVED_PROPS = {
|
|
715
|
-
key: true,
|
|
716
|
-
ref: true,
|
|
717
|
-
__self: true,
|
|
718
|
-
__source: true
|
|
719
|
-
};
|
|
720
|
-
var specialPropKeyWarningShown;
|
|
721
|
-
var specialPropRefWarningShown;
|
|
722
|
-
var didWarnAboutStringRefs;
|
|
723
|
-
|
|
724
|
-
{
|
|
725
|
-
didWarnAboutStringRefs = {};
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
function hasValidRef(config) {
|
|
729
|
-
{
|
|
730
|
-
if (hasOwnProperty.call(config, 'ref')) {
|
|
731
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
732
|
-
|
|
733
|
-
if (getter && getter.isReactWarning) {
|
|
734
|
-
return false;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
return config.ref !== undefined;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
function hasValidKey(config) {
|
|
743
|
-
{
|
|
744
|
-
if (hasOwnProperty.call(config, 'key')) {
|
|
745
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
746
|
-
|
|
747
|
-
if (getter && getter.isReactWarning) {
|
|
748
|
-
return false;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
return config.key !== undefined;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
757
|
-
{
|
|
758
|
-
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
759
|
-
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
760
|
-
|
|
761
|
-
if (!didWarnAboutStringRefs[componentName]) {
|
|
762
|
-
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
|
763
|
-
|
|
764
|
-
didWarnAboutStringRefs[componentName] = true;
|
|
765
|
-
}
|
|
783
|
+
if (getter && getter.isReactWarning) {
|
|
784
|
+
return false;
|
|
785
|
+
}
|
|
766
786
|
}
|
|
767
787
|
}
|
|
788
|
+
|
|
789
|
+
return config.key !== undefined;
|
|
768
790
|
}
|
|
769
791
|
|
|
770
792
|
function defineKeyPropWarningGetter(props, displayName) {
|
|
@@ -773,7 +795,7 @@ function defineKeyPropWarningGetter(props, displayName) {
|
|
|
773
795
|
if (!specialPropKeyWarningShown) {
|
|
774
796
|
specialPropKeyWarningShown = true;
|
|
775
797
|
|
|
776
|
-
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://
|
|
798
|
+
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://react.dev/link/special-props)', displayName);
|
|
777
799
|
}
|
|
778
800
|
};
|
|
779
801
|
|
|
@@ -785,27 +807,26 @@ function defineKeyPropWarningGetter(props, displayName) {
|
|
|
785
807
|
}
|
|
786
808
|
}
|
|
787
809
|
|
|
788
|
-
function
|
|
810
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
789
811
|
{
|
|
790
|
-
var
|
|
791
|
-
if (!specialPropRefWarningShown) {
|
|
792
|
-
specialPropRefWarningShown = true;
|
|
812
|
+
var componentName = getComponentNameFromType(this.type);
|
|
793
813
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
};
|
|
814
|
+
if (!didWarnAboutElementRef[componentName]) {
|
|
815
|
+
didWarnAboutElementRef[componentName] = true;
|
|
797
816
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
817
|
+
error('Accessing element.ref was removed in React 19. ref is now a ' + 'regular prop. It will be removed from the JSX Element ' + 'type in a future release.');
|
|
818
|
+
} // An undefined `element.ref` is coerced to `null` for
|
|
819
|
+
// backwards compatibility.
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
var refProp = this.props.ref;
|
|
823
|
+
return refProp !== undefined ? refProp : null;
|
|
803
824
|
}
|
|
804
825
|
}
|
|
805
826
|
/**
|
|
806
827
|
* Factory method to create a new React element. This no longer adheres to
|
|
807
828
|
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
808
|
-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
829
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
|
|
809
830
|
* if something is a React Element.
|
|
810
831
|
*
|
|
811
832
|
* @param {*} type
|
|
@@ -824,18 +845,65 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
824
845
|
*/
|
|
825
846
|
|
|
826
847
|
|
|
827
|
-
|
|
828
|
-
var
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
//
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
ref
|
|
835
|
-
|
|
836
|
-
//
|
|
837
|
-
|
|
838
|
-
|
|
848
|
+
function ReactElement(type, key, _ref, self, source, owner, props) {
|
|
849
|
+
var ref;
|
|
850
|
+
|
|
851
|
+
{
|
|
852
|
+
// When enableRefAsProp is on, ignore whatever was passed as the ref
|
|
853
|
+
// argument and treat `props.ref` as the source of truth. The only thing we
|
|
854
|
+
// use this for is `element.ref`, which will log a deprecation warning on
|
|
855
|
+
// access. In the next release, we can remove `element.ref` as well as the
|
|
856
|
+
// `ref` argument.
|
|
857
|
+
var refProp = props.ref; // An undefined `element.ref` is coerced to `null` for
|
|
858
|
+
// backwards compatibility.
|
|
859
|
+
|
|
860
|
+
ref = refProp !== undefined ? refProp : null;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
var element;
|
|
864
|
+
|
|
865
|
+
{
|
|
866
|
+
// In dev, make `ref` a non-enumerable property with a warning. It's non-
|
|
867
|
+
// enumerable so that test matchers and serializers don't access it and
|
|
868
|
+
// trigger the warning.
|
|
869
|
+
//
|
|
870
|
+
// `ref` will be removed from the element completely in a future release.
|
|
871
|
+
element = {
|
|
872
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
873
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
874
|
+
// Built-in properties that belong on the element
|
|
875
|
+
type: type,
|
|
876
|
+
key: key,
|
|
877
|
+
props: props,
|
|
878
|
+
// Record the component responsible for creating this element.
|
|
879
|
+
_owner: owner
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
if (ref !== null) {
|
|
883
|
+
Object.defineProperty(element, 'ref', {
|
|
884
|
+
enumerable: false,
|
|
885
|
+
get: elementRefGetterWithDeprecationWarning
|
|
886
|
+
});
|
|
887
|
+
} else {
|
|
888
|
+
// Don't warn on access if a ref is not given. This reduces false
|
|
889
|
+
// positives in cases where a test serializer uses
|
|
890
|
+
// getOwnPropertyDescriptors to compare objects, like Jest does, which is
|
|
891
|
+
// a problem because it bypasses non-enumerability.
|
|
892
|
+
//
|
|
893
|
+
// So unfortunately this will trigger a false positive warning in Jest
|
|
894
|
+
// when the diff is printed:
|
|
895
|
+
//
|
|
896
|
+
// expect(<div ref={ref} />).toEqual(<span ref={ref} />);
|
|
897
|
+
//
|
|
898
|
+
// A bit sketchy, but this is what we've done for the `props.key` and
|
|
899
|
+
// `props.ref` accessors for years, which implies it will be good enough
|
|
900
|
+
// for `element.ref`, too. Let's see if anyone complains.
|
|
901
|
+
Object.defineProperty(element, 'ref', {
|
|
902
|
+
enumerable: false,
|
|
903
|
+
value: null
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
839
907
|
|
|
840
908
|
{
|
|
841
909
|
// The validation flag is currently mutative. We put it on
|
|
@@ -852,21 +920,13 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
852
920
|
enumerable: false,
|
|
853
921
|
writable: true,
|
|
854
922
|
value: false
|
|
855
|
-
}); //
|
|
856
|
-
|
|
857
|
-
Object.defineProperty(element, '_self', {
|
|
858
|
-
configurable: false,
|
|
859
|
-
enumerable: false,
|
|
860
|
-
writable: false,
|
|
861
|
-
value: self
|
|
862
|
-
}); // Two elements created in two different places should be considered
|
|
863
|
-
// equal for testing purposes and therefore we hide it from enumeration.
|
|
923
|
+
}); // debugInfo contains Server Component debug information.
|
|
864
924
|
|
|
865
|
-
Object.defineProperty(element, '
|
|
925
|
+
Object.defineProperty(element, '_debugInfo', {
|
|
866
926
|
configurable: false,
|
|
867
927
|
enumerable: false,
|
|
868
|
-
writable:
|
|
869
|
-
value:
|
|
928
|
+
writable: true,
|
|
929
|
+
value: null
|
|
870
930
|
});
|
|
871
931
|
|
|
872
932
|
if (Object.freeze) {
|
|
@@ -876,7 +936,8 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
876
936
|
}
|
|
877
937
|
|
|
878
938
|
return element;
|
|
879
|
-
}
|
|
939
|
+
}
|
|
940
|
+
var didWarnAboutKeySpread = {};
|
|
880
941
|
/**
|
|
881
942
|
* https://github.com/reactjs/rfcs/pull/107
|
|
882
943
|
* @param {*} type
|
|
@@ -884,11 +945,78 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
884
945
|
* @param {string} key
|
|
885
946
|
*/
|
|
886
947
|
|
|
887
|
-
function jsxDEV(type, config, maybeKey, source, self) {
|
|
948
|
+
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) {
|
|
888
949
|
{
|
|
889
|
-
|
|
950
|
+
if (!isValidElementType(type)) {
|
|
951
|
+
// This is an invalid element type.
|
|
952
|
+
//
|
|
953
|
+
// We warn in this case but don't throw. We expect the element creation to
|
|
954
|
+
// succeed and there will likely be errors in render.
|
|
955
|
+
var info = '';
|
|
956
|
+
|
|
957
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
958
|
+
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.";
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
var typeString;
|
|
962
|
+
|
|
963
|
+
if (type === null) {
|
|
964
|
+
typeString = 'null';
|
|
965
|
+
} else if (isArray(type)) {
|
|
966
|
+
typeString = 'array';
|
|
967
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
968
|
+
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
|
|
969
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
970
|
+
} else {
|
|
971
|
+
typeString = typeof type;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
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);
|
|
975
|
+
} else {
|
|
976
|
+
// This is a valid element type.
|
|
977
|
+
// Skip key warning if the type isn't valid since our key validation logic
|
|
978
|
+
// doesn't expect a non-string/function type and can throw confusing
|
|
979
|
+
// errors. We don't want exception behavior to differ between dev and
|
|
980
|
+
// prod. (Rendering will throw with a helpful message and as soon as the
|
|
981
|
+
// type is fixed, the key warnings will appear.)
|
|
982
|
+
var children = config.children;
|
|
983
|
+
|
|
984
|
+
if (children !== undefined) {
|
|
985
|
+
if (isStaticChildren) {
|
|
986
|
+
if (isArray(children)) {
|
|
987
|
+
for (var i = 0; i < children.length; i++) {
|
|
988
|
+
validateChildKeys(children[i], type);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
if (Object.freeze) {
|
|
992
|
+
Object.freeze(children);
|
|
993
|
+
}
|
|
994
|
+
} else {
|
|
995
|
+
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.');
|
|
996
|
+
}
|
|
997
|
+
} else {
|
|
998
|
+
validateChildKeys(children, type);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
} // Warn about key spread regardless of whether the type is valid.
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
1005
|
+
var componentName = getComponentNameFromType(type);
|
|
1006
|
+
var keys = Object.keys(config).filter(function (k) {
|
|
1007
|
+
return k !== 'key';
|
|
1008
|
+
});
|
|
1009
|
+
var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
|
|
1010
|
+
|
|
1011
|
+
if (!didWarnAboutKeySpread[componentName + beforeExample]) {
|
|
1012
|
+
var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
|
|
1013
|
+
|
|
1014
|
+
error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
|
|
1015
|
+
|
|
1016
|
+
didWarnAboutKeySpread[componentName + beforeExample] = true;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
890
1019
|
|
|
891
|
-
var props = {};
|
|
892
1020
|
var key = null;
|
|
893
1021
|
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
894
1022
|
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
@@ -913,84 +1041,61 @@ function jsxDEV(type, config, maybeKey, source, self) {
|
|
|
913
1041
|
key = '' + config.key;
|
|
914
1042
|
}
|
|
915
1043
|
|
|
916
|
-
if (hasValidRef(config))
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1044
|
+
if (hasValidRef(config)) ;
|
|
1045
|
+
|
|
1046
|
+
var props;
|
|
1047
|
+
|
|
1048
|
+
if (!('key' in config)) {
|
|
1049
|
+
// If key was not spread in, we can reuse the original props object. This
|
|
1050
|
+
// only works for `jsx`, not `createElement`, because `jsx` is a compiler
|
|
1051
|
+
// target and the compiler always passes a new object. For `createElement`,
|
|
1052
|
+
// we can't assume a new object is passed every time because it can be
|
|
1053
|
+
// called manually.
|
|
1054
|
+
//
|
|
1055
|
+
// Spreading key is a warning in dev. In a future release, we will not
|
|
1056
|
+
// remove a spread key from the props object. (But we'll still warn.) We'll
|
|
1057
|
+
// always pass the object straight through.
|
|
1058
|
+
props = config;
|
|
1059
|
+
} else {
|
|
1060
|
+
// We need to remove reserved props (key, prop, ref). Create a fresh props
|
|
1061
|
+
// object and copy over all the non-reserved props. We don't use `delete`
|
|
1062
|
+
// because in V8 it will deopt the object to dictionary mode.
|
|
1063
|
+
props = {};
|
|
1064
|
+
|
|
1065
|
+
for (var propName in config) {
|
|
1066
|
+
// Skip over reserved prop names
|
|
1067
|
+
if (propName !== 'key' && (enableRefAsProp )) {
|
|
1068
|
+
{
|
|
1069
|
+
props[propName] = config[propName];
|
|
1070
|
+
}
|
|
935
1071
|
}
|
|
936
1072
|
}
|
|
937
1073
|
}
|
|
938
1074
|
|
|
939
|
-
if (key ||
|
|
1075
|
+
if (key || !enableRefAsProp ) {
|
|
940
1076
|
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
941
1077
|
|
|
942
1078
|
if (key) {
|
|
943
1079
|
defineKeyPropWarningGetter(props, displayName);
|
|
944
1080
|
}
|
|
945
|
-
|
|
946
|
-
if (ref) {
|
|
947
|
-
defineRefPropWarningGetter(props, displayName);
|
|
948
|
-
}
|
|
949
1081
|
}
|
|
950
1082
|
|
|
951
|
-
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
956
|
-
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1083
|
+
var element = ReactElement(type, key, ref, self, source, getOwner(), props);
|
|
957
1084
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
if (element) {
|
|
961
|
-
var owner = element._owner;
|
|
962
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
963
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
964
|
-
} else {
|
|
965
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
1085
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
1086
|
+
validateFragmentProps(element);
|
|
966
1087
|
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
1088
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
{
|
|
973
|
-
propTypesMisspellWarningShown = false;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Verifies the object is a ReactElement.
|
|
977
|
-
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
978
|
-
* @param {?object} object
|
|
979
|
-
* @return {boolean} True if `object` is a ReactElement.
|
|
980
|
-
* @final
|
|
981
|
-
*/
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
function isValidElement(object) {
|
|
985
|
-
{
|
|
986
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1089
|
+
return element;
|
|
987
1090
|
}
|
|
988
1091
|
}
|
|
989
1092
|
|
|
990
1093
|
function getDeclarationErrorAddendum() {
|
|
991
1094
|
{
|
|
992
|
-
|
|
993
|
-
|
|
1095
|
+
var owner = getOwner();
|
|
1096
|
+
|
|
1097
|
+
if (owner) {
|
|
1098
|
+
var name = getComponentNameFromType(owner.type);
|
|
994
1099
|
|
|
995
1100
|
if (name) {
|
|
996
1101
|
return '\n\nCheck the render method of `' + name + '`.';
|
|
@@ -1000,42 +1105,72 @@ function getDeclarationErrorAddendum() {
|
|
|
1000
1105
|
return '';
|
|
1001
1106
|
}
|
|
1002
1107
|
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Ensure that every element either is passed in a static location, in an
|
|
1110
|
+
* array with an explicit keys property defined, or in an object literal
|
|
1111
|
+
* with valid key property.
|
|
1112
|
+
*
|
|
1113
|
+
* @internal
|
|
1114
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
1115
|
+
* @param {*} parentType node's parent's type.
|
|
1116
|
+
*/
|
|
1117
|
+
|
|
1003
1118
|
|
|
1004
|
-
function
|
|
1119
|
+
function validateChildKeys(node, parentType) {
|
|
1005
1120
|
{
|
|
1006
|
-
if (
|
|
1007
|
-
|
|
1008
|
-
var lineNumber = source.lineNumber;
|
|
1009
|
-
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
1121
|
+
if (typeof node !== 'object' || !node) {
|
|
1122
|
+
return;
|
|
1010
1123
|
}
|
|
1011
1124
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
/**
|
|
1016
|
-
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
1017
|
-
* object keys are not valid. This allows us to keep track of children between
|
|
1018
|
-
* updates.
|
|
1019
|
-
*/
|
|
1020
|
-
|
|
1125
|
+
if (node.$$typeof === REACT_CLIENT_REFERENCE) ; else if (isArray(node)) {
|
|
1126
|
+
for (var i = 0; i < node.length; i++) {
|
|
1127
|
+
var child = node[i];
|
|
1021
1128
|
|
|
1022
|
-
|
|
1129
|
+
if (isValidElement(child)) {
|
|
1130
|
+
validateExplicitKey(child, parentType);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
} else if (isValidElement(node)) {
|
|
1134
|
+
// This element was passed in a valid location.
|
|
1135
|
+
if (node._store) {
|
|
1136
|
+
node._store.validated = true;
|
|
1137
|
+
}
|
|
1138
|
+
} else {
|
|
1139
|
+
var iteratorFn = getIteratorFn(node);
|
|
1023
1140
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1141
|
+
if (typeof iteratorFn === 'function') {
|
|
1142
|
+
// Entry iterators used to provide implicit keys,
|
|
1143
|
+
// but now we print a separate warning for them later.
|
|
1144
|
+
if (iteratorFn !== node.entries) {
|
|
1145
|
+
var iterator = iteratorFn.call(node);
|
|
1027
1146
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1147
|
+
if (iterator !== node) {
|
|
1148
|
+
var step;
|
|
1030
1149
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1150
|
+
while (!(step = iterator.next()).done) {
|
|
1151
|
+
if (isValidElement(step.value)) {
|
|
1152
|
+
validateExplicitKey(step.value, parentType);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1033
1157
|
}
|
|
1034
1158
|
}
|
|
1035
|
-
|
|
1036
|
-
return info;
|
|
1037
1159
|
}
|
|
1038
1160
|
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Verifies the object is a ReactElement.
|
|
1163
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
1164
|
+
* @param {?object} object
|
|
1165
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
1166
|
+
* @final
|
|
1167
|
+
*/
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
function isValidElement(object) {
|
|
1171
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1172
|
+
}
|
|
1173
|
+
var ownerHasKeyUseWarning = {};
|
|
1039
1174
|
/**
|
|
1040
1175
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
1041
1176
|
* This element is in an array. The array could grow and shrink or be
|
|
@@ -1048,7 +1183,6 @@ function getCurrentComponentErrorInfo(parentType) {
|
|
|
1048
1183
|
* @param {*} parentType element's parent's type.
|
|
1049
1184
|
*/
|
|
1050
1185
|
|
|
1051
|
-
|
|
1052
1186
|
function validateExplicitKey(element, parentType) {
|
|
1053
1187
|
{
|
|
1054
1188
|
if (!element._store || element._store.validated || element.key != null) {
|
|
@@ -1068,111 +1202,51 @@ function validateExplicitKey(element, parentType) {
|
|
|
1068
1202
|
|
|
1069
1203
|
var childOwner = '';
|
|
1070
1204
|
|
|
1071
|
-
if (element && element._owner && element._owner !==
|
|
1072
|
-
|
|
1073
|
-
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
setCurrentlyValidatingElement$1(element);
|
|
1205
|
+
if (element && element._owner != null && element._owner !== getOwner()) {
|
|
1206
|
+
var ownerName = null;
|
|
1077
1207
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* Ensure that every element either is passed in a static location, in an
|
|
1085
|
-
* array with an explicit keys property defined, or in an object literal
|
|
1086
|
-
* with valid key property.
|
|
1087
|
-
*
|
|
1088
|
-
* @internal
|
|
1089
|
-
* @param {ReactNode} node Statically passed child of any type.
|
|
1090
|
-
* @param {*} parentType node's parent's type.
|
|
1091
|
-
*/
|
|
1208
|
+
if (typeof element._owner.tag === 'number') {
|
|
1209
|
+
ownerName = getComponentNameFromType(element._owner.type);
|
|
1210
|
+
} else if (typeof element._owner.name === 'string') {
|
|
1211
|
+
ownerName = element._owner.name;
|
|
1212
|
+
} // Give the component that originally created this child.
|
|
1092
1213
|
|
|
1093
1214
|
|
|
1094
|
-
|
|
1095
|
-
{
|
|
1096
|
-
if (typeof node !== 'object') {
|
|
1097
|
-
return;
|
|
1215
|
+
childOwner = " It was passed a child from " + ownerName + ".";
|
|
1098
1216
|
}
|
|
1099
1217
|
|
|
1100
|
-
|
|
1101
|
-
for (var i = 0; i < node.length; i++) {
|
|
1102
|
-
var child = node[i];
|
|
1218
|
+
setCurrentlyValidatingElement(element);
|
|
1103
1219
|
|
|
1104
|
-
|
|
1105
|
-
validateExplicitKey(child, parentType);
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
} else if (isValidElement(node)) {
|
|
1109
|
-
// This element was passed in a valid location.
|
|
1110
|
-
if (node._store) {
|
|
1111
|
-
node._store.validated = true;
|
|
1112
|
-
}
|
|
1113
|
-
} else if (node) {
|
|
1114
|
-
var iteratorFn = getIteratorFn(node);
|
|
1220
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1115
1221
|
|
|
1116
|
-
|
|
1117
|
-
// Entry iterators used to provide implicit keys,
|
|
1118
|
-
// but now we print a separate warning for them later.
|
|
1119
|
-
if (iteratorFn !== node.entries) {
|
|
1120
|
-
var iterator = iteratorFn.call(node);
|
|
1121
|
-
var step;
|
|
1122
|
-
|
|
1123
|
-
while (!(step = iterator.next()).done) {
|
|
1124
|
-
if (isValidElement(step.value)) {
|
|
1125
|
-
validateExplicitKey(step.value, parentType);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1222
|
+
setCurrentlyValidatingElement(null);
|
|
1131
1223
|
}
|
|
1132
1224
|
}
|
|
1133
|
-
/**
|
|
1134
|
-
* Given an element, validate that its props follow the propTypes definition,
|
|
1135
|
-
* provided by the type.
|
|
1136
|
-
*
|
|
1137
|
-
* @param {ReactElement} element
|
|
1138
|
-
*/
|
|
1139
1225
|
|
|
1140
|
-
|
|
1141
|
-
function validatePropTypes(element) {
|
|
1226
|
+
function setCurrentlyValidatingElement(element) {
|
|
1142
1227
|
{
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
var propTypes;
|
|
1150
|
-
|
|
1151
|
-
if (typeof type === 'function') {
|
|
1152
|
-
propTypes = type.propTypes;
|
|
1153
|
-
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
1154
|
-
// Inner props are checked in the reconciler.
|
|
1155
|
-
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
1156
|
-
propTypes = type.propTypes;
|
|
1228
|
+
if (element) {
|
|
1229
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type);
|
|
1230
|
+
ReactSharedInternals.setExtraStackFrame(stack);
|
|
1157
1231
|
} else {
|
|
1158
|
-
|
|
1232
|
+
ReactSharedInternals.setExtraStackFrame(null);
|
|
1159
1233
|
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1160
1236
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
1165
|
-
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1166
|
-
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
1237
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
1238
|
+
{
|
|
1239
|
+
var info = getDeclarationErrorAddendum();
|
|
1167
1240
|
|
|
1168
|
-
|
|
1241
|
+
if (!info) {
|
|
1242
|
+
var parentName = getComponentNameFromType(parentType);
|
|
1169
1243
|
|
|
1170
|
-
|
|
1244
|
+
if (parentName) {
|
|
1245
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1246
|
+
}
|
|
1171
1247
|
}
|
|
1172
1248
|
|
|
1173
|
-
|
|
1174
|
-
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
1175
|
-
}
|
|
1249
|
+
return info;
|
|
1176
1250
|
}
|
|
1177
1251
|
}
|
|
1178
1252
|
/**
|
|
@@ -1182,6 +1256,7 @@ function validatePropTypes(element) {
|
|
|
1182
1256
|
|
|
1183
1257
|
|
|
1184
1258
|
function validateFragmentProps(fragment) {
|
|
1259
|
+
// TODO: Move this to render phase instead of at element creation.
|
|
1185
1260
|
{
|
|
1186
1261
|
var keys = Object.keys(fragment.props);
|
|
1187
1262
|
|
|
@@ -1189,127 +1264,20 @@ function validateFragmentProps(fragment) {
|
|
|
1189
1264
|
var key = keys[i];
|
|
1190
1265
|
|
|
1191
1266
|
if (key !== 'children' && key !== 'key') {
|
|
1192
|
-
setCurrentlyValidatingElement
|
|
1267
|
+
setCurrentlyValidatingElement(fragment);
|
|
1193
1268
|
|
|
1194
1269
|
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1195
1270
|
|
|
1196
|
-
setCurrentlyValidatingElement
|
|
1271
|
+
setCurrentlyValidatingElement(null);
|
|
1197
1272
|
break;
|
|
1198
1273
|
}
|
|
1199
1274
|
}
|
|
1200
|
-
|
|
1201
|
-
if (fragment.ref !== null) {
|
|
1202
|
-
setCurrentlyValidatingElement$1(fragment);
|
|
1203
|
-
|
|
1204
|
-
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1205
|
-
|
|
1206
|
-
setCurrentlyValidatingElement$1(null);
|
|
1207
|
-
}
|
|
1208
1275
|
}
|
|
1209
1276
|
}
|
|
1210
1277
|
|
|
1211
|
-
var
|
|
1212
|
-
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
1213
|
-
{
|
|
1214
|
-
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
1215
|
-
// succeed and there will likely be errors in render.
|
|
1216
|
-
|
|
1217
|
-
if (!validType) {
|
|
1218
|
-
var info = '';
|
|
1219
|
-
|
|
1220
|
-
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1221
|
-
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.";
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
1225
|
-
|
|
1226
|
-
if (sourceInfo) {
|
|
1227
|
-
info += sourceInfo;
|
|
1228
|
-
} else {
|
|
1229
|
-
info += getDeclarationErrorAddendum();
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
var typeString;
|
|
1233
|
-
|
|
1234
|
-
if (type === null) {
|
|
1235
|
-
typeString = 'null';
|
|
1236
|
-
} else if (isArray(type)) {
|
|
1237
|
-
typeString = 'array';
|
|
1238
|
-
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1239
|
-
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
|
|
1240
|
-
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1241
|
-
} else {
|
|
1242
|
-
typeString = typeof type;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
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);
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
1249
|
-
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
1250
|
-
|
|
1251
|
-
if (element == null) {
|
|
1252
|
-
return element;
|
|
1253
|
-
} // Skip key warning if the type isn't valid since our key validation logic
|
|
1254
|
-
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
1255
|
-
// We don't want exception behavior to differ between dev and prod.
|
|
1256
|
-
// (Rendering will throw with a helpful message and as soon as the type is
|
|
1257
|
-
// fixed, the key warnings will appear.)
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
if (validType) {
|
|
1261
|
-
var children = props.children;
|
|
1262
|
-
|
|
1263
|
-
if (children !== undefined) {
|
|
1264
|
-
if (isStaticChildren) {
|
|
1265
|
-
if (isArray(children)) {
|
|
1266
|
-
for (var i = 0; i < children.length; i++) {
|
|
1267
|
-
validateChildKeys(children[i], type);
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
if (Object.freeze) {
|
|
1271
|
-
Object.freeze(children);
|
|
1272
|
-
}
|
|
1273
|
-
} else {
|
|
1274
|
-
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.');
|
|
1275
|
-
}
|
|
1276
|
-
} else {
|
|
1277
|
-
validateChildKeys(children, type);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
{
|
|
1283
|
-
if (hasOwnProperty.call(props, 'key')) {
|
|
1284
|
-
var componentName = getComponentNameFromType(type);
|
|
1285
|
-
var keys = Object.keys(props).filter(function (k) {
|
|
1286
|
-
return k !== 'key';
|
|
1287
|
-
});
|
|
1288
|
-
var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
|
|
1289
|
-
|
|
1290
|
-
if (!didWarnAboutKeySpread[componentName + beforeExample]) {
|
|
1291
|
-
var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
|
|
1292
|
-
|
|
1293
|
-
error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
|
|
1294
|
-
|
|
1295
|
-
didWarnAboutKeySpread[componentName + beforeExample] = true;
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
|
1301
|
-
validateFragmentProps(element);
|
|
1302
|
-
} else {
|
|
1303
|
-
validatePropTypes(element);
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
return element;
|
|
1307
|
-
}
|
|
1308
|
-
} // These two functions exist to still get child warnings in dev
|
|
1309
|
-
|
|
1310
|
-
var jsxDEV$1 = jsxWithValidation ;
|
|
1278
|
+
var jsxDEV = jsxDEV$1 ;
|
|
1311
1279
|
|
|
1312
1280
|
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
1313
|
-
exports.jsxDEV = jsxDEV
|
|
1281
|
+
exports.jsxDEV = jsxDEV;
|
|
1314
1282
|
})();
|
|
1315
1283
|
}
|