React Development
React Development
1
* [Link]
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var hasSymbol = typeof Symbol === 'function' && [Link];
var REACT_ELEMENT_TYPE = hasSymbol ? [Link]('[Link]') : 0xeac7;
var REACT_PORTAL_TYPE = hasSymbol ? [Link]('[Link]') : 0xeaca;
var REACT_FRAGMENT_TYPE = hasSymbol ? [Link]('[Link]') : 0xeacb;
var REACT_STRICT_MODE_TYPE = hasSymbol ? [Link]('react.strict_mode') : 0xeacc;
var REACT_PROFILER_TYPE = hasSymbol ? [Link]('[Link]') : 0xead2;
var REACT_PROVIDER_TYPE = hasSymbol ? [Link]('[Link]') : 0xeacd;
var REACT_CONTEXT_TYPE = hasSymbol ? [Link]('[Link]') : 0xeace; // TODO:
We don't use AsyncMode or ConcurrentMode anymore. They were temporary
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? [Link]('react.concurrent_mode') :
0xeacf;
var REACT_FORWARD_REF_TYPE = hasSymbol ? [Link]('react.forward_ref') : 0xead0;
var REACT_SUSPENSE_TYPE = hasSymbol ? [Link]('[Link]') : 0xead1;
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? [Link]('react.suspense_list') :
0xead8;
var REACT_MEMO_TYPE = hasSymbol ? [Link]('[Link]') : 0xead3;
var REACT_LAZY_TYPE = hasSymbol ? [Link]('[Link]') : 0xead4;
var REACT_BLOCK_TYPE = hasSymbol ? [Link]('[Link]') : 0xead9;
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? [Link]('[Link]') : 0xead5;
var REACT_RESPONDER_TYPE = hasSymbol ? [Link]('[Link]') : 0xead6;
var REACT_SCOPE_TYPE = hasSymbol ? [Link]('[Link]') : 0xead7;
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && [Link];
var FAUX_ITERATOR_SYMBOL = '@@iterator';
function getIteratorFn(maybeIterable) {
if (maybeIterable === null || typeof maybeIterable !== 'object') {
return null;
}
/**
* Keeps track of the current dispatcher.
*/
var ReactCurrentDispatcher = {
/**
* @internal
* @type {ReactComponent}
*/
current: null
};
/**
* Keeps track of the current batch's configuration such as how long an update
* should suspend for if it needs to.
*/
var ReactCurrentBatchConfig = {
suspense: null
};
/**
* Keeps track of the current owner.
*
* The current owner is the component who should own any components that are
* currently being constructed.
*/
var ReactCurrentOwner = {
/**
* @internal
* @type {ReactComponent}
*/
current: null
};
if (source) {
var path = [Link];
var fileName = [Link](BEFORE_SLASH_RE, '');
{
// In DEV, include code for a common special case:
// prefer "folder/[Link]" instead of just "[Link]".
if (/^index\./.test(fileName)) {
var match = [Link](BEFORE_SLASH_RE);
if (match) {
var pathBeforeSlash = match[1];
if (pathBeforeSlash) {
var folderName = [Link](BEFORE_SLASH_RE, '');
fileName = folderName + '/' + fileName;
}
}
}
}
var Resolved = 1;
function refineResolvedLazyComponent(lazyComponent) {
return lazyComponent._status === Resolved ? lazyComponent._result : null;
}
function getComponentName(type) {
if (type == null) {
// Host root, text node or just invalid type.
return null;
}
{
if (typeof [Link] === 'number') {
error('Received an unexpected object in getComponentName(). ' + 'This is
likely a bug in React. Please file an issue.');
}
}
switch (type) {
case REACT_FRAGMENT_TYPE:
return 'Fragment';
case REACT_PORTAL_TYPE:
return 'Portal';
case REACT_PROFILER_TYPE:
return "Profiler";
case REACT_STRICT_MODE_TYPE:
return 'StrictMode';
case REACT_SUSPENSE_TYPE:
return 'Suspense';
case REACT_SUSPENSE_LIST_TYPE:
return 'SuspenseList';
}
case REACT_PROVIDER_TYPE:
return '[Link]';
case REACT_FORWARD_REF_TYPE:
return getWrappedName(type, [Link], 'ForwardRef');
case REACT_MEMO_TYPE:
return getComponentName([Link]);
case REACT_BLOCK_TYPE:
return getComponentName([Link]);
case REACT_LAZY_TYPE:
{
var thenable = type;
var resolvedThenable = refineResolvedLazyComponent(thenable);
if (resolvedThenable) {
return getComponentName(resolvedThenable);
}
break;
}
}
}
return null;
}
{
// Stack implementation injected by the current renderer.
[Link] = null;
[Link] = function () {
var stack = ''; // Add an extra top frame while an element is being validated
if (currentlyValidatingElement) {
var name = getComponentName([Link]);
var owner = currentlyValidatingElement._owner;
stack += describeComponentFrame(name, currentlyValidatingElement._source,
owner && getComponentName([Link]));
} // Delegate to the injected renderer-specific implementation
var impl = [Link];
if (impl) {
stack += impl() || '';
}
return stack;
};
}
/**
* Used by act() to track whether you're inside an act() scope.
*/
var IsSomeRendererActing = {
current: false
};
var ReactSharedInternals = {
ReactCurrentDispatcher: ReactCurrentDispatcher,
ReactCurrentBatchConfig: ReactCurrentBatchConfig,
ReactCurrentOwner: ReactCurrentOwner,
IsSomeRendererActing: IsSomeRendererActing,
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
assign: _assign
};
{
_assign(ReactSharedInternals, {
// These should not be included in production.
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
// TODO: remove in React 17.0.
ReactComponentTreeHook: {}
});
}
function warn(format) {
{
for (var _len = [Link], args = new Array(_len > 1 ? _len - 1 : 0),
_key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
if (!hasExistingStack) {
var ReactDebugCurrentFrame = [Link];
var stack = [Link]();
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
var argIndex = 0;
var message = 'Warning: ' + [Link](/%s/g, function () {
return args[argIndex++];
});
throw new Error(message);
} catch (x) {}
}
}
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
return;
}
error("Can't call %s on a component that is not yet mounted. " + 'This is a no-
op, but it might indicate a bug in your application. ' + 'Instead, assign to
`[Link]` directly or define a `state = {};` ' + 'class property with the
desired state in the %s component.', callerName, componentName);
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
}
}
/**
* This is the abstract API for an update queue.
*/
var ReactNoopUpdateQueue = {
/**
* Checks whether or not this composite component is mounted.
* @param {ReactClass} publicInstance The instance we want to test.
* @return {boolean} True if mounted, false otherwise.
* @protected
* @final
*/
isMounted: function (publicInstance) {
return false;
},
/**
* Forces an update. This should only be invoked when it is known with
* certainty that we are **not** in a DOM transaction.
*
* You may want to call this when you know that some deeper aspect of the
* component's state has changed but `setState` was not called.
*
* This will not invoke `shouldComponentUpdate`, but it will invoke
* `componentWillUpdate` and `componentDidUpdate`.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {?function} callback Called after component is updated.
* @param {?string} callerName name of the calling function in the public API.
* @internal
*/
enqueueForceUpdate: function (publicInstance, callback, callerName) {
warnNoop(publicInstance, 'forceUpdate');
},
/**
* Replaces all of the state. Always use this or `setState` to mutate state.
* You should treat `[Link]` as immutable.
*
* There is no guarantee that `[Link]` will be immediately updated, so
* accessing `[Link]` after calling this method may return the old value.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} completeState Next state.
* @param {?function} callback Called after component is updated.
* @param {?string} callerName name of the calling function in the public API.
* @internal
*/
enqueueReplaceState: function (publicInstance, completeState, callback,
callerName) {
warnNoop(publicInstance, 'replaceState');
},
/**
* Sets a subset of the state. This only exists because _pendingState is
* internal. This provides a merging strategy that is not available to deep
* properties which is confusing. TODO: Expose pendingState or don't use it
* during the merge.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} partialState Next partial state to be merged with state.
* @param {?function} callback Called after component is updated.
* @param {?string} Name of the calling function in the public API.
* @internal
*/
enqueueSetState: function (publicInstance, partialState, callback, callerName) {
warnNoop(publicInstance, 'setState');
}
};
{
[Link](emptyObject);
}
/**
* Base class helpers for the updating state of a component.
*/
[Link] = emptyObject; // We initialize the default updater but the real one
gets injected by the
// renderer.
[Link] = {};
/**
* Sets a subset of the state. Always use this to mutate
* state. You should treat `[Link]` as immutable.
*
* There is no guarantee that `[Link]` will be immediately updated, so
* accessing `[Link]` after calling this method may return the old value.
*
* There is no guarantee that calls to `setState` will run synchronously,
* as they may eventually be batched together. You can provide an optional
* callback that will be executed when the call to setState is actually
* completed.
*
* When a function is provided to setState, it will be called at some point in
* the future (not synchronously). It will be called with the up to date
* component arguments (state, props, context). These values can be different
* from this.* because your function may be called after receiveProps but before
* shouldComponentUpdate, and this new state, props, and context will not yet be
* assigned to this.
*
* @param {object|function} partialState Next partial state or function to
* produce next partial state to be merged with current state.
* @param {?function} callback Called after state is updated.
* @final
* @protected
*/
{
var deprecatedAPIs = {
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and
pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
replaceState: ['replaceState', 'Refactor your code to use setState instead (see
' + '[Link]
};
function ComponentDummy() {}
[Link] = [Link];
/**
* Convenience component with default shallow equality check for sCU.
*/
[Link] = emptyObject;
[Link] = updater || ReactNoopUpdateQueue;
}
_assign(pureComponentPrototype, [Link]);
[Link] = true;
{
[Link](refObject);
}
return refObject;
}
function hasValidRef(config) {
{
if ([Link](config, 'ref')) {
var getter = [Link](config, 'ref').get;
function hasValidKey(config) {
{
if ([Link](config, 'key')) {
var getter = [Link](config, 'key').get;
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. ([Link]
special-props)', displayName);
}
}
};
[Link] = true;
[Link](props, 'key', {
get: warnAboutAccessingKey,
configurable: true
});
}
[Link] = true;
[Link](props, 'ref', {
get: warnAboutAccessingRef,
configurable: true
});
}
function warnIfStringRefCannotBeAutoConverted(config) {
{
if (typeof [Link] === 'string' && [Link] &&
config.__self && [Link] !== config.__self) {
var componentName = getComponentName([Link]);
if (!didWarnAboutStringRefs[componentName]) {
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: ' + '[Link]
getComponentName([Link]), [Link]);
didWarnAboutStringRefs[componentName] = true;
}
}
}
}
/**
* Factory method to create a new React element. This no longer adheres to
* the class pattern, so do not use new to call it. Also, instanceof check
* will not work. Instead test $$typeof field against [Link]('[Link]')
to check
* if something is a React Element.
*
* @param {*} type
* @param {*} props
* @param {*} key
* @param {string|object} ref
* @param {*} owner
* @param {*} self A *temporary* helper to detect places where `this` is
* different from the `owner` when [Link] is called, so that we
* can warn. We want to get rid of owner and replace string `ref`s with arrow
* functions, and as long as `this` and owner are the same, there will be no
* change in behavior.
* @param {*} source An annotation object (added by a transpiler or otherwise)
* indicating filename, line number, and/or other information.
* @internal
*/
var ReactElement = function (type, key, ref, self, source, owner, props) {
var element = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: REACT_ELEMENT_TYPE,
// Built-in properties that belong on the element
type: type,
key: key,
ref: ref,
props: props,
// Record the component responsible for creating this element.
_owner: owner
};
{
// The validation flag is currently mutative. We put it on
// an external backing store so that we can freeze the whole object.
// This can be replaced with a WeakMap once they are implemented in
// commonly used development environments.
element._store = {}; // To make comparing ReactElements easier for testing
purposes, we make
// the validation flag non-enumerable (where possible, which should
// include every environment we run tests in), so the test framework
// ignores it.
[Link](element._store, 'validated', {
configurable: false,
enumerable: false,
writable: true,
value: false
}); // self and source are DEV only properties.
[Link](element, '_self', {
configurable: false,
enumerable: false,
writable: false,
value: self
}); // Two elements created in two different places should be considered
// equal for testing purposes and therefore we hide it from enumeration.
[Link](element, '_source', {
configurable: false,
enumerable: false,
writable: false,
value: source
});
if ([Link]) {
[Link]([Link]);
[Link](element);
}
}
return element;
};
/**
* Create and return a new ReactElement of the given type.
* See [Link]
*/
if (config != null) {
if (hasValidRef(config)) {
ref = [Link];
{
warnIfStringRefCannotBeAutoConverted(config);
}
}
if (hasValidKey(config)) {
key = '' + [Link];
}
if (childrenLength === 1) {
[Link] = children;
} else if (childrenLength > 1) {
var childArray = Array(childrenLength);
{
if ([Link]) {
[Link](childArray);
}
}
[Link] = childArray;
} // Resolve default props
{
if (key || ref) {
var displayName = typeof type === 'function' ? [Link] || [Link]
|| 'Unknown' : type;
if (key) {
defineKeyPropWarningGetter(props, displayName);
}
if (ref) {
defineRefPropWarningGetter(props, displayName);
}
}
}
if (hasValidKey(config)) {
key = '' + [Link];
} // Remaining properties override existing props
var defaultProps;
if (childrenLength === 1) {
[Link] = children;
} else if (childrenLength > 1) {
var childArray = Array(childrenLength);
[Link] = childArray;
}
function isValidElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof ===
REACT_ELEMENT_TYPE;
}
function escape(key) {
var escapeRegex = /[=:]/g;
var escaperLookup = {
'=': '=0',
':': '=2'
};
var escapedString = ('' + key).replace(escapeRegex, function (match) {
return escaperLookup[match];
});
return '$' + escapedString;
}
/**
* TODO: Test that a single child and an array with one item have the same key
* pattern.
*/
function escapeUserProvidedKey(text) {
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
}
case 'object':
switch (children.$$typeof) {
case REACT_ELEMENT_TYPE:
case REACT_PORTAL_TYPE:
invokeCallback = true;
}
}
}
if (invokeCallback) {
callback(traverseContext, children, // If it's the only child, treat the name
as if it was wrapped in an array
// so that it's consistent if the number of children grows.
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
return 1;
}
var child;
var nextName;
var subtreeCount = 0; // Count of children found in the current subtree.
if ([Link](children)) {
for (var i = 0; i < [Link]; i++) {
child = children[i];
nextName = nextNamePrefix + getComponentKey(child, i);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback,
traverseContext);
}
} else {
var iteratorFn = getIteratorFn(children);
{
// Warn about using Maps as children
if (iteratorFn === [Link]) {
if (!didWarnAboutMaps) {
warn('Using Maps as children is deprecated and will be removed in ' +
'a future major release. Consider converting children to ' + 'an array of keyed
ReactElements instead.');
}
didWarnAboutMaps = true;
}
}
{
addendum = ' If you meant to render a collection of children, use an array
' + 'instead.' + [Link]();
}
{
{
throw Error( "Objects are not valid as a React child (found: " +
(childrenString === '[object Object]' ? 'object with keys {' +
[Link](children).join(', ') + '}' : childrenString) + ")." + addendum );
}
}
}
}
return subtreeCount;
}
/**
* Traverses children that are typically specified as `[Link]`, but
* might also be specified through attributes:
*
* - `traverseAllChildren([Link], ...)`
* - `traverseAllChildren([Link], ...)`
*
* The `traverseContext` is an optional argument that is passed through the
* entire traversal. It can be used to store accumulations or anything else that
* the callback might find relevant.
*
* @param {?*} children Children tree object.
* @param {!function} callback To invoke upon traversing each child.
* @param {?*} traverseContext Context for traversal.
* @return {!number} The number of children in this subtree.
*/
return [Link](36);
}
if ([Link](mappedChild)) {
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
return c;
});
} else if (mappedChild != null) {
if (isValidElement(mappedChild)) {
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and
old keys if they differ, just as
// traverseAllChildren used to do for objects as children
keyPrefix + ([Link] && (!child || [Link] !== [Link]) ?
escapeUserProvidedKey([Link]) + '/' : '') + childKey);
}
[Link](mappedChild);
}
}
if (prefix != null) {
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
}
function countChildren(children) {
return traverseAllChildren(children, function () {
return null;
}, null);
}
/**
* Flatten a children object (typically specified as `[Link]`) and
* return an array with appropriately re-keyed children.
*
* See [Link]
*/
function toArray(children) {
var result = [];
mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
return child;
});
return result;
}
/**
* Returns the first child in a collection of children and verifies that there
* is only one child in the collection.
*
* See [Link]
*
* The current implementation of this function assumes that a single child gets
* passed without a wrapper, but the purpose of this helper function is to
* abstract away the particular structure of children.
*
* @param {?object} children Child collection structure.
* @return {ReactElement} The first and only `ReactElement` contained in the
* structure.
*/
function onlyChild(children) {
if (!isValidElement(children)) {
{
throw Error( "[Link] expected to receive a single React element
child." );
}
}
return children;
}
var context = {
$$typeof: REACT_CONTEXT_TYPE,
_calculateChangedBits: calculateChangedBits,
// As a workaround to support multiple concurrent renderers, we categorize
// some renderers as primary and others as secondary. We only expect
// there to be two concurrent renderers at most: React Native (primary) and
// Fabric (secondary); React DOM (primary) and React ART (secondary).
// Secondary renderers store their context values on separate fields.
_currentValue: defaultValue,
_currentValue2: defaultValue,
// Used to track how many concurrent renderers this context currently
// supports within in a single renderer. Such as parallel server rendering.
_threadCount: 0,
// These are circular
Provider: null,
Consumer: null
};
[Link] = {
$$typeof: REACT_PROVIDER_TYPE,
_context: context
};
var hasWarnedAboutUsingNestedContextConsumers = false;
var hasWarnedAboutUsingConsumerProvider = false;
{
// A separate object, but proxies back to the original context object for
// backwards compatibility. It has a different $$typeof, so we can properly
// warn for the incorrect usage of Context as a Consumer.
var Consumer = {
$$typeof: REACT_CONTEXT_TYPE,
_context: context,
_calculateChangedBits: context._calculateChangedBits
}; // $FlowFixMe: Flow complains about not setting a value, which is
intentional here
[Link](Consumer, {
Provider: {
get: function () {
if (!hasWarnedAboutUsingConsumerProvider) {
hasWarnedAboutUsingConsumerProvider = true;
return [Link];
},
set: function (_Provider) {
[Link] = _Provider;
}
},
_currentValue: {
get: function () {
return context._currentValue;
},
set: function (_currentValue) {
context._currentValue = _currentValue;
}
},
_currentValue2: {
get: function () {
return context._currentValue2;
},
set: function (_currentValue2) {
context._currentValue2 = _currentValue2;
}
},
_threadCount: {
get: function () {
return context._threadCount;
},
set: function (_threadCount) {
context._threadCount = _threadCount;
}
},
Consumer: {
get: function () {
if (!hasWarnedAboutUsingNestedContextConsumers) {
hasWarnedAboutUsingNestedContextConsumers = true;
return [Link];
}
}
}); // $FlowFixMe: Flow complains about missing properties because it doesn't
understand defineProperty
[Link] = Consumer;
}
{
context._currentRenderer = null;
context._currentRenderer2 = null;
}
return context;
}
function lazy(ctor) {
var lazyType = {
$$typeof: REACT_LAZY_TYPE,
_ctor: ctor,
// React uses these fields to store the result.
_status: -1,
_result: null
};
{
// In production, this would just set it on the object.
var defaultProps;
var propTypes;
[Link](lazyType, {
defaultProps: {
configurable: true,
get: function () {
return defaultProps;
},
set: function (newDefaultProps) {
error('[Link](...): It is not supported to assign `defaultProps` to '
+ 'a lazy component import. Either specify them where the component ' + 'is
defined, or create a wrapping component around it.');
[Link](lazyType, 'defaultProps', {
enumerable: true
});
}
},
propTypes: {
configurable: true,
get: function () {
return propTypes;
},
set: function (newPropTypes) {
error('[Link](...): It is not supported to assign `propTypes` to ' +
'a lazy component import. Either specify them where the component ' + 'is defined,
or create a wrapping component around it.');
[Link](lazyType, 'propTypes', {
enumerable: true
});
}
}
});
}
return lazyType;
}
function forwardRef(render) {
{
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
error('forwardRef requires a render function but received a `memo` ' +
'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
} else if (typeof render !== 'function') {
error('forwardRef requires a render function but was given %s.', render ===
null ? 'null' : typeof render);
} else {
if ([Link] !== 0 && [Link] !== 2) {
error('forwardRef render functions accept exactly two parameters: props and
ref. %s', [Link] === 1 ? 'Did you forget to use the ref parameter?' : 'Any
additional parameter will be undefined.');
}
}
if (render != null) {
if ([Link] != null || [Link] != null) {
error('forwardRef render functions do not support propTypes or
defaultProps. ' + 'Did you accidentally pass a React component?');
}
}
}
return {
$$typeof: REACT_FORWARD_REF_TYPE,
render: render
};
}
function isValidElementType(type) {
return typeof type === 'string' || typeof type === 'function' || // Note: its
typeof might be other than 'symbol' or 'number' if it's a polyfill.
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type ===
REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type ===
REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type ===
'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof
=== REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof ===
REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof ===
REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof
=== REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
}
function memo(type, compare) {
{
if (!isValidElementType(type)) {
error('memo: The first argument must be a component. Instead ' + 'received:
%s', type === null ? 'null' : typeof type);
}
}
return {
$$typeof: REACT_MEMO_TYPE,
type: type,
compare: compare === undefined ? null : compare
};
}
function resolveDispatcher() {
var dispatcher = [Link];
return dispatcher;
}
{
if (unstable_observedBits !== undefined) {
error('useContext() second argument is reserved for future ' + 'use in React.
Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof
unstable_observedBits === 'number' && [Link](arguments[2]) ? '\n\nDid you
call [Link](useContext)? ' + 'Calling Hooks inside a loop is not supported. ' +
'Learn more at [Link] : '');
} // TODO: add a more generic warning for invalid values.
var propTypesMisspellWarningShown;
{
propTypesMisspellWarningShown = false;
}
function getDeclarationErrorAddendum() {
if ([Link]) {
var name = getComponentName([Link]);
if (name) {
return '\n\nCheck the render method of `' + name + '`.';
}
}
return '';
}
function getSourceInfoErrorAddendum(source) {
if (source !== undefined) {
var fileName = [Link](/^.*[\\\/]/, '');
var lineNumber = [Link];
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
}
return '';
}
function getSourceInfoErrorAddendumForProps(elementProps) {
if (elementProps !== null && elementProps !== undefined) {
return getSourceInfoErrorAddendum(elementProps.__source);
}
return '';
}
/**
* Warn if there's no key explicitly set on dynamic arrays of children or
* object keys are not valid. This allows us to keep track of children between
* updates.
*/
function getCurrentComponentErrorInfo(parentType) {
var info = getDeclarationErrorAddendum();
if (!info) {
var parentName = typeof parentType === 'string' ? parentType :
[Link] || [Link];
if (parentName) {
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
}
}
return info;
}
/**
* Warn if the element doesn't have an explicit key assigned to it.
* This element is in an array. The array could grow and shrink or be
* reordered. All children that haven't already been validated are required to
* have a "key" property assigned to it. Error statuses are cached so a warning
* will only be shown once.
*
* @internal
* @param {ReactElement} element Element that requires a key.
* @param {*} parentType element's parent's type.
*/
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
return;
}
setCurrentlyValidatingElement(element);
{
error('Each child in a list should have a unique "key" prop.' + '%s%s See
[Link] for more information.', currentComponentErrorInfo,
childOwner);
}
setCurrentlyValidatingElement(null);
}
/**
* Ensure that every element either is passed in a static location, in an
* array with an explicit keys property defined, or in an object literal
* with valid key property.
*
* @internal
* @param {ReactNode} node Statically passed child of any type.
* @param {*} parentType node's parent's type.
*/
if ([Link](node)) {
for (var i = 0; i < [Link]; i++) {
var child = node[i];
if (isValidElement(child)) {
validateExplicitKey(child, parentType);
}
}
} else if (isValidElement(node)) {
// This element was passed in a valid location.
if (node._store) {
node._store.validated = true;
}
} else if (node) {
var iteratorFn = getIteratorFn(node);
function validatePropTypes(element) {
{
var type = [Link];
if (type === null || type === undefined || typeof type === 'string') {
return;
}
if (propTypes) {
setCurrentlyValidatingElement(element);
checkPropTypes(propTypes, [Link], 'prop', name,
[Link]);
setCurrentlyValidatingElement(null);
} else if ([Link] !== undefined && !propTypesMisspellWarningShown) {
propTypesMisspellWarningShown = true;
function validateFragmentProps(fragment) {
{
setCurrentlyValidatingElement(fragment);
var keys = [Link]([Link]);
break;
}
}
setCurrentlyValidatingElement(null);
}
}
function createElementWithValidation(type, props, children) {
var validType = isValidElementType(type); // We warn in this case but don't
throw. We expect the element creation to
// succeed and there will likely be errors in render.
if (!validType) {
var info = '';
if (type === undefined || typeof type === 'object' && type !== null &&
[Link](type).length === 0) {
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.";
}
if (sourceInfo) {
info += sourceInfo;
} else {
info += getDeclarationErrorAddendum();
}
var typeString;
{
error('[Link]: type is invalid -- expected a string (for ' +
'built-in components) or a class/function (for composite ' + 'components) but got:
%s.%s', typeString, info);
}
}
if (element == null) {
return element;
} // Skip key warning if the type isn't valid since our key validation logic
// doesn't expect a non-string/function type and can throw confusing errors.
// We don't want exception behavior to differ between dev and prod.
// (Rendering will throw with a helpful message and as soon as the type is
// fixed, the key warnings will appear.)
if (validType) {
for (var i = 2; i < [Link]; i++) {
validateChildKeys(arguments[i], type);
}
}
return element;
}
var didWarnAboutDeprecatedCreateFactory = false;
function createFactoryWithValidation(type) {
var validatedFactory = [Link](null, type);
[Link] = type;
{
if (!didWarnAboutDeprecatedCreateFactory) {
didWarnAboutDeprecatedCreateFactory = true;
[Link](validatedFactory, 'type', {
enumerable: false,
get: function () {
warn('[Link] is deprecated. Access the class directly ' + 'before
passing it to createFactory.');
[Link](this, 'type', {
value: type
});
return type;
}
});
}
return validatedFactory;
}
function cloneElementWithValidation(element, props, children) {
var newElement = [Link](this, arguments);
validatePropTypes(newElement);
return newElement;
}
try {
var frozenObject = [Link]({});
var testMap = new Map([[frozenObject, null]]);
var testSet = new Set([frozenObject]); // This is necessary for Rollup to not
consider these unused.
// [Link]
// TODO: we can remove these if Rollup fixes the bug.
[Link](0, 0);
[Link](0);
} catch (e) {
}
}