main
js 883 lines 27.1 KB
Raw
1 /** @license React v0.14.10
2 * react-jsx-runtime.development.js
3 *
4 * Copyright (c) Meta Platforms, Inc. and affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10 'use strict';
11
12 if (process.env.NODE_ENV !== "production") {
13 (function() {
14 'use strict';
15
16 var React = require('react');
17
18 // ATTENTION
19 // When adding new symbols to this file,
20 // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
21 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
22 // nor polyfill, then a plain number is used for performance.
23 var REACT_ELEMENT_TYPE = 0xeac7;
24 var REACT_PORTAL_TYPE = 0xeaca;
25 exports.Fragment = 0xeacb;
26 var REACT_STRICT_MODE_TYPE = 0xeacc;
27 var REACT_PROFILER_TYPE = 0xead2;
28 var REACT_PROVIDER_TYPE = 0xeacd;
29 var REACT_CONTEXT_TYPE = 0xeace;
30 var REACT_FORWARD_REF_TYPE = 0xead0;
31 var REACT_SUSPENSE_TYPE = 0xead1;
32 var REACT_SUSPENSE_LIST_TYPE = 0xead8;
33 var REACT_MEMO_TYPE = 0xead3;
34 var REACT_LAZY_TYPE = 0xead4;
35 var REACT_BLOCK_TYPE = 0xead9;
36 var REACT_SERVER_BLOCK_TYPE = 0xeada;
37 var REACT_FUNDAMENTAL_TYPE = 0xead5;
38 var REACT_SCOPE_TYPE = 0xead7;
39 var REACT_OPAQUE_ID_TYPE = 0xeae0;
40 var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
41 var REACT_OFFSCREEN_TYPE = 0xeae2;
42 var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
43
44 if (typeof Symbol === 'function' && Symbol.for) {
45 var symbolFor = Symbol.for;
46 REACT_ELEMENT_TYPE = symbolFor('react.element');
47 REACT_PORTAL_TYPE = symbolFor('react.portal');
48 exports.Fragment = symbolFor('react.fragment');
49 REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
50 REACT_PROFILER_TYPE = symbolFor('react.profiler');
51 REACT_PROVIDER_TYPE = symbolFor('react.provider');
52 REACT_CONTEXT_TYPE = symbolFor('react.context');
53 REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
54 REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
55 REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
56 REACT_MEMO_TYPE = symbolFor('react.memo');
57 REACT_LAZY_TYPE = symbolFor('react.lazy');
58 REACT_BLOCK_TYPE = symbolFor('react.block');
59 REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
60 REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
61 REACT_SCOPE_TYPE = symbolFor('react.scope');
62 REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
63 REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
64 REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
65 REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
66 }
67
68 var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
69 var FAUX_ITERATOR_SYMBOL = '@@iterator';
70 function getIteratorFn(maybeIterable) {
71 if (maybeIterable === null || typeof maybeIterable !== 'object') {
72 return null;
73 }
74
75 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
76
77 if (typeof maybeIterator === 'function') {
78 return maybeIterator;
79 }
80
81 return null;
82 }
83
84 function error(format) {
85 {
86 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
87 args[_key2 - 1] = arguments[_key2];
88 }
89
90 printWarning('error', format, args);
91 }
92 }
93
94 function printWarning(level, format, args) {
95 // When changing this logic, you might want to also
96 // update consoleWithStackDev.www.js as well.
97 {
98 var stack = '';
99
100 if (stack !== '') {
101 format += '%s';
102 args = args.concat([stack]);
103 }
104
105 var argsWithFormat = args.map(function (item) {
106 return '' + item;
107 }); // Careful: RN currently depends on this prefix
108
109 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
110 // breaks IE9: https://github.com/facebook/react/issues/13610
111 // eslint-disable-next-line react-internal/no-production-logging
112
113 Function.prototype.apply.call(console[level], console, argsWithFormat);
114 }
115 }
116
117 // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
118
119 var enableScopeAPI = false; // Experimental Create Event Handle API.
120
121 function isValidElementType(type) {
122 if (typeof type === 'string' || typeof type === 'function') {
123 return true;
124 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
125
126
127 if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
128 return true;
129 }
130
131 if (typeof type === 'object' && type !== null) {
132 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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
133 return true;
134 }
135 }
136
137 return false;
138 }
139
140
141 var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
142 function describeComponentFrame (name, source, ownerName) {
143 var sourceInfo = '';
144
145 if (source) {
146 var path = source.fileName;
147 var fileName = path.replace(BEFORE_SLASH_RE, '');
148
149 {
150 // In DEV, include code for a common special case:
151 // prefer "folder/index.js" instead of just "index.js".
152 if (/^index\./.test(fileName)) {
153 var match = path.match(BEFORE_SLASH_RE);
154
155 if (match) {
156 var pathBeforeSlash = match[1];
157
158 if (pathBeforeSlash) {
159 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
160 fileName = folderName + '/' + fileName;
161 }
162 }
163 }
164 }
165
166 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
167 } else if (ownerName) {
168 sourceInfo = ' (created by ' + ownerName + ')';
169 }
170
171 return '\n in ' + (name || 'Unknown') + sourceInfo;
172 }
173
174 var Resolved = 1;
175 function refineResolvedLazyComponent(lazyComponent) {
176 return lazyComponent._status === Resolved ? lazyComponent._result : null;
177 }
178
179 function getWrappedName(outerType, innerType, wrapperName) {
180 var functionName = innerType.displayName || innerType.name || '';
181 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
182 }
183
184 function getComponentName(type) {
185 if (type == null) {
186 // Host root, text node or just invalid type.
187 return null;
188 }
189
190 {
191 if (typeof type.tag === 'number') {
192 error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
193 }
194 }
195
196 if (typeof type === 'function') {
197 return type.displayName || type.name || null;
198 }
199
200 if (typeof type === 'string') {
201 return type;
202 }
203
204 switch (type) {
205 case exports.Fragment:
206 return 'Fragment';
207
208 case REACT_PORTAL_TYPE:
209 return 'Portal';
210
211 case REACT_PROFILER_TYPE:
212 return "Profiler";
213
214 case REACT_STRICT_MODE_TYPE:
215 return 'StrictMode';
216
217 case REACT_SUSPENSE_TYPE:
218 return 'Suspense';
219
220 case REACT_SUSPENSE_LIST_TYPE:
221 return 'SuspenseList';
222 }
223
224 if (typeof type === 'object') {
225 switch (type.$$typeof) {
226 case REACT_CONTEXT_TYPE:
227 return 'Context.Consumer';
228
229 case REACT_PROVIDER_TYPE:
230 return 'Context.Provider';
231
232 case REACT_FORWARD_REF_TYPE:
233 return getWrappedName(type, type.render, 'ForwardRef');
234
235 case REACT_MEMO_TYPE:
236 return getComponentName(type.type);
237
238 case REACT_BLOCK_TYPE:
239 return getComponentName(type.render);
240
241 case REACT_LAZY_TYPE:
242 {
243 var thenable = type;
244 var resolvedThenable = refineResolvedLazyComponent(thenable);
245
246 if (resolvedThenable) {
247 return getComponentName(resolvedThenable);
248 }
249
250 break;
251 }
252 }
253 }
254
255 return null;
256 }
257
258 var loggedTypeFailures = {};
259 var currentlyValidatingElement = null;
260
261 function setCurrentlyValidatingElement(element) {
262 {
263 currentlyValidatingElement = element;
264 }
265 }
266
267 function checkPropTypes(typeSpecs, values, location, componentName, element) {
268 {
269 // $FlowFixMe This is okay but Flow doesn't know it.
270 var has = Function.call.bind(Object.prototype.hasOwnProperty);
271
272 for (var typeSpecName in typeSpecs) {
273 if (has(typeSpecs, typeSpecName)) {
274 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
275 // fail the render phase where it didn't fail before. So we log it.
276 // After these have been cleaned up, we'll let them throw.
277
278 try {
279 // This is intentionally an invariant that gets caught. It's the same
280 // behavior as without this statement except with a better message.
281 if (typeof typeSpecs[typeSpecName] !== 'function') {
282 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`.');
283 err.name = 'Invariant Violation';
284 throw err;
285 }
286
287 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
288 } catch (ex) {
289 error$1 = ex;
290 }
291
292 if (error$1 && !(error$1 instanceof Error)) {
293 setCurrentlyValidatingElement(element);
294
295 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);
296
297 setCurrentlyValidatingElement(null);
298 }
299
300 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
301 // Only monitor this failure once because there tends to be a lot of the
302 // same error.
303 loggedTypeFailures[error$1.message] = true;
304 setCurrentlyValidatingElement(element);
305
306 error('Failed %s type: %s', location, error$1.message);
307
308 setCurrentlyValidatingElement(null);
309 }
310 }
311 }
312 }
313 }
314
315 var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
316 var hasOwnProperty = Object.prototype.hasOwnProperty;
317 var RESERVED_PROPS = {
318 key: true,
319 ref: true,
320 __self: true,
321 __source: true
322 };
323 var specialPropKeyWarningShown;
324 var specialPropRefWarningShown;
325 var didWarnAboutStringRefs;
326
327 {
328 didWarnAboutStringRefs = {};
329 }
330
331 function hasValidRef(config) {
332 {
333 if (hasOwnProperty.call(config, 'ref')) {
334 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
335
336 if (getter && getter.isReactWarning) {
337 return false;
338 }
339 }
340 }
341
342 return config.ref !== undefined;
343 }
344
345 function hasValidKey(config) {
346 {
347 if (hasOwnProperty.call(config, 'key')) {
348 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
349
350 if (getter && getter.isReactWarning) {
351 return false;
352 }
353 }
354 }
355
356 return config.key !== undefined;
357 }
358
359 function defineKeyPropWarningGetter(props, displayName) {
360 {
361 var warnAboutAccessingKey = function () {
362 if (!specialPropKeyWarningShown) {
363 specialPropKeyWarningShown = true;
364
365 error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
366 }
367 };
368
369 warnAboutAccessingKey.isReactWarning = true;
370 Object.defineProperty(props, 'key', {
371 get: warnAboutAccessingKey,
372 configurable: true
373 });
374 }
375 }
376
377 function defineRefPropWarningGetter(props, displayName) {
378 {
379 var warnAboutAccessingRef = function () {
380 if (!specialPropRefWarningShown) {
381 specialPropRefWarningShown = true;
382
383 error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
384 }
385 };
386
387 warnAboutAccessingRef.isReactWarning = true;
388 Object.defineProperty(props, 'ref', {
389 get: warnAboutAccessingRef,
390 configurable: true
391 });
392 }
393 }
394 /**
395 * Factory method to create a new React element. This no longer adheres to
396 * the class pattern, so do not use new to call it. Also, instanceof check
397 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
398 * if something is a React Element.
399 *
400 * @param {*} type
401 * @param {*} props
402 * @param {*} key
403 * @param {string|object} ref
404 * @param {*} owner
405 * @param {*} self A *temporary* helper to detect places where `this` is
406 * different from the `owner` when React.createElement is called, so that we
407 * can warn. We want to get rid of owner and replace string `ref`s with arrow
408 * functions, and as long as `this` and owner are the same, there will be no
409 * change in behavior.
410 * @param {*} source An annotation object (added by a transpiler or otherwise)
411 * indicating filename, line number, and/or other information.
412 * @internal
413 */
414
415
416 var ReactElement = function (type, key, ref, self, source, owner, props) {
417 var element = {
418 // This tag allows us to uniquely identify this as a React Element
419 $$typeof: REACT_ELEMENT_TYPE,
420 // Built-in properties that belong on the element
421 type: type,
422 key: key,
423 ref: ref,
424 props: props,
425 // Record the component responsible for creating this element.
426 _owner: owner
427 };
428
429 {
430 // The validation flag is currently mutative. We put it on
431 // an external backing store so that we can freeze the whole object.
432 // This can be replaced with a WeakMap once they are implemented in
433 // commonly used development environments.
434 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
435 // the validation flag non-enumerable (where possible, which should
436 // include every environment we run tests in), so the test framework
437 // ignores it.
438
439 Object.defineProperty(element._store, 'validated', {
440 configurable: false,
441 enumerable: false,
442 writable: true,
443 value: false
444 }); // self and source are DEV only properties.
445
446 Object.defineProperty(element, '_self', {
447 configurable: false,
448 enumerable: false,
449 writable: false,
450 value: self
451 }); // Two elements created in two different places should be considered
452 // equal for testing purposes and therefore we hide it from enumeration.
453
454 Object.defineProperty(element, '_source', {
455 configurable: false,
456 enumerable: false,
457 writable: false,
458 value: source
459 });
460
461 if (Object.freeze) {
462 Object.freeze(element.props);
463 Object.freeze(element);
464 }
465 }
466
467 return element;
468 };
469 /**
470 * https://github.com/reactjs/rfcs/pull/107
471 * @param {*} type
472 * @param {object} props
473 * @param {string} key
474 */
475
476 function jsxDEV(type, config, maybeKey, source, self) {
477 {
478 var propName; // Reserved names are extracted
479
480 var props = {};
481 var key = null;
482 var ref = null; // Currently, key can be spread in as a prop. This causes a potential
483 // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
484 // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
485 // but as an intermediary step, we will use jsxDEV for everything except
486 // <div {...props} key="Hi" />, because we aren't currently able to tell if
487 // key is explicitly declared to be undefined or not.
488
489 if (maybeKey !== undefined) {
490 key = '' + maybeKey;
491 }
492
493 if (hasValidKey(config)) {
494 key = '' + config.key;
495 }
496
497 if (hasValidRef(config)) {
498 ref = config.ref;
499 } // Remaining properties are added to a new props object
500
501
502 for (propName in config) {
503 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
504 props[propName] = config[propName];
505 }
506 } // Resolve default props
507
508
509 if (type && type.defaultProps) {
510 var defaultProps = type.defaultProps;
511
512 for (propName in defaultProps) {
513 if (props[propName] === undefined) {
514 props[propName] = defaultProps[propName];
515 }
516 }
517 }
518
519 if (key || ref) {
520 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
521
522 if (key) {
523 defineKeyPropWarningGetter(props, displayName);
524 }
525
526 if (ref) {
527 defineRefPropWarningGetter(props, displayName);
528 }
529 }
530
531 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
532 }
533 }
534
535 var ReactCurrentOwner$1 = require('react/lib/ReactCurrentOwner');
536
537 function setCurrentlyValidatingElement$1(element) {
538 currentlyValidatingElement = element;
539 }
540
541 var propTypesMisspellWarningShown;
542
543 {
544 propTypesMisspellWarningShown = false;
545 }
546 /**
547 * Verifies the object is a ReactElement.
548 * See https://reactjs.org/docs/react-api.html#isvalidelement
549 * @param {?object} object
550 * @return {boolean} True if `object` is a ReactElement.
551 * @final
552 */
553
554 function isValidElement(object) {
555 {
556 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
557 }
558 }
559
560 function getDeclarationErrorAddendum() {
561 {
562 if (ReactCurrentOwner$1.current) {
563 var name = ReactCurrentOwner$1.current.getName();
564
565 if (name) {
566 return '\n\nCheck the render method of `' + name + '`.';
567 }
568 }
569
570 return '';
571 }
572 }
573
574 function getSourceInfoErrorAddendum(source) {
575 {
576 if (source !== undefined) {
577 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
578 var lineNumber = source.lineNumber;
579 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
580 }
581
582 return '';
583 }
584 }
585 /**
586 * Warn if there's no key explicitly set on dynamic arrays of children or
587 * object keys are not valid. This allows us to keep track of children between
588 * updates.
589 */
590
591
592 var ownerHasKeyUseWarning = {};
593
594 function getCurrentComponentErrorInfo(parentType) {
595 {
596 var info = getDeclarationErrorAddendum();
597
598 if (!info) {
599 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
600
601 if (parentName) {
602 info = "\n\nCheck the top-level render call using <" + parentName + ">.";
603 }
604 }
605
606 return info;
607 }
608 }
609 /**
610 * Warn if the element doesn't have an explicit key assigned to it.
611 * This element is in an array. The array could grow and shrink or be
612 * reordered. All children that haven't already been validated are required to
613 * have a "key" property assigned to it. Error statuses are cached so a warning
614 * will only be shown once.
615 *
616 * @internal
617 * @param {ReactElement} element Element that requires a key.
618 * @param {*} parentType element's parent's type.
619 */
620
621
622 function validateExplicitKey(element, parentType) {
623 {
624 if (!element._store || element._store.validated || element.key != null) {
625 return;
626 }
627
628 element._store.validated = true;
629 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
630
631 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
632 return;
633 }
634
635 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
636 // property, it may be the creator of the child that's responsible for
637 // assigning it a key.
638
639 var childOwner = '';
640
641 if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
642 // Give the component that originally created this child.
643 childOwner = " It was passed a child from " + element._owner.getName() + ".";
644 }
645
646 setCurrentlyValidatingElement$1(element);
647
648 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
649
650 setCurrentlyValidatingElement$1(null);
651 }
652 }
653 /**
654 * Ensure that every element either is passed in a static location, in an
655 * array with an explicit keys property defined, or in an object literal
656 * with valid key property.
657 *
658 * @internal
659 * @param {ReactNode} node Statically passed child of any type.
660 * @param {*} parentType node's parent's type.
661 */
662
663
664 function validateChildKeys(node, parentType) {
665 {
666 if (typeof node !== 'object') {
667 return;
668 }
669
670 if (Array.isArray(node)) {
671 for (var i = 0; i < node.length; i++) {
672 var child = node[i];
673
674 if (isValidElement(child)) {
675 validateExplicitKey(child, parentType);
676 }
677 }
678 } else if (isValidElement(node)) {
679 // This element was passed in a valid location.
680 if (node._store) {
681 node._store.validated = true;
682 }
683 } else if (node) {
684 var iteratorFn = getIteratorFn(node);
685
686 if (typeof iteratorFn === 'function') {
687 // Entry iterators used to provide implicit keys,
688 // but now we print a separate warning for them later.
689 if (iteratorFn !== node.entries) {
690 var iterator = iteratorFn.call(node);
691 var step;
692
693 while (!(step = iterator.next()).done) {
694 if (isValidElement(step.value)) {
695 validateExplicitKey(step.value, parentType);
696 }
697 }
698 }
699 }
700 }
701 }
702 }
703 /**
704 * Given an element, validate that its props follow the propTypes definition,
705 * provided by the type.
706 *
707 * @param {ReactElement} element
708 */
709
710
711 function validatePropTypes(element) {
712 {
713 var type = element.type;
714
715 if (type === null || type === undefined || typeof type === 'string') {
716 return;
717 }
718
719 var propTypes;
720
721 if (typeof type === 'function') {
722 propTypes = type.propTypes;
723 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
724 // Inner props are checked in the reconciler.
725 type.$$typeof === REACT_MEMO_TYPE)) {
726 propTypes = type.propTypes;
727 } else {
728 return;
729 }
730
731 if (propTypes) {
732 // Intentionally inside to avoid triggering lazy initializers:
733 var name = getComponentName(type);
734 checkPropTypes(propTypes, element.props, 'prop', name, element);
735 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
736 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
737
738 var _name = getComponentName(type);
739
740 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
741 }
742
743 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
744 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
745 }
746 }
747 }
748 /**
749 * Given a fragment, validate that it can only be provided with fragment props
750 * @param {ReactElement} fragment
751 */
752
753
754 function validateFragmentProps(fragment) {
755 {
756 var keys = Object.keys(fragment.props);
757
758 for (var i = 0; i < keys.length; i++) {
759 var key = keys[i];
760
761 if (key !== 'children' && key !== 'key') {
762 setCurrentlyValidatingElement$1(fragment);
763
764 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
765
766 setCurrentlyValidatingElement$1(null);
767 break;
768 }
769 }
770
771 if (fragment.ref !== null) {
772 setCurrentlyValidatingElement$1(fragment);
773
774 error('Invalid attribute `ref` supplied to `React.Fragment`.');
775
776 setCurrentlyValidatingElement$1(null);
777 }
778 }
779 }
780
781 function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
782 {
783 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
784 // succeed and there will likely be errors in render.
785
786 if (!validType) {
787 var info = '';
788
789 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
790 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.";
791 }
792
793 var sourceInfo = getSourceInfoErrorAddendum(source);
794
795 if (sourceInfo) {
796 info += sourceInfo;
797 } else {
798 info += getDeclarationErrorAddendum();
799 }
800
801 var typeString;
802
803 if (type === null) {
804 typeString = 'null';
805 } else if (Array.isArray(type)) {
806 typeString = 'array';
807 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
808 typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
809 info = ' Did you accidentally export a JSX literal instead of a component?';
810 } else {
811 typeString = typeof type;
812 }
813
814 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);
815 }
816
817 var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
818 // TODO: Drop this when these are no longer allowed as the type argument.
819
820 if (element == null) {
821 return element;
822 } // Skip key warning if the type isn't valid since our key validation logic
823 // doesn't expect a non-string/function type and can throw confusing errors.
824 // We don't want exception behavior to differ between dev and prod.
825 // (Rendering will throw with a helpful message and as soon as the type is
826 // fixed, the key warnings will appear.)
827
828
829 if (validType) {
830 var children = props.children;
831
832 if (children !== undefined) {
833 if (isStaticChildren) {
834 if (Array.isArray(children)) {
835 for (var i = 0; i < children.length; i++) {
836 validateChildKeys(children[i], type);
837 }
838
839 if (Object.freeze) {
840 Object.freeze(children);
841 }
842 } else {
843 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.');
844 }
845 } else {
846 validateChildKeys(children, type);
847 }
848 }
849 }
850
851 if (type === exports.Fragment) {
852 validateFragmentProps(element);
853 } else {
854 validatePropTypes(element);
855 }
856
857 return element;
858 }
859 } // These two functions exist to still get child warnings in dev
860 // even with the prod transform. This means that jsxDEV is purely
861 // opt-in behavior for better messages but that we won't stop
862 // giving you warnings if you use production apis.
863
864 function jsxWithValidationStatic(type, props, key) {
865 {
866 return jsxWithValidation(type, props, key, true);
867 }
868 }
869 function jsxWithValidationDynamic(type, props, key) {
870 {
871 return jsxWithValidation(type, props, key, false);
872 }
873 }
874
875 var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
876 // for now we can ship identical prod functions
877
878 var jsxs = jsxWithValidationStatic ;
879
880 exports.jsx = jsx;
881 exports.jsxs = jsxs;
882 })();
883 }