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