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