: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (hasValidKey(config)) {
checkKeyStringCoercion(config.key);
self = config.__self === undefined ? null : config.__self;
source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
for (propName in config) {
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
props[propName] = config[propName];
} // Children can be more than one argument, and those are transferred onto
// the newly allocated props object.
var childrenLength = arguments.length - 2;
if (childrenLength === 1) {
props.children = children;
} else if (childrenLength > 1) {
var childArray = Array(childrenLength);
for (var i = 0; i < childrenLength; i++) {
childArray[i] = arguments[i + 2];
Object.freeze(childArray);
props.children = childArray;
} // Resolve default props
if (type && type.defaultProps) {
var defaultProps = type.defaultProps;
for (propName in defaultProps) {
if (props[propName] === undefined) {
props[propName] = defaultProps[propName];
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
defineKeyPropWarningGetter(props, displayName);
defineRefPropWarningGetter(props, displayName);
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
function cloneAndReplaceKey(oldElement, newKey) {
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
* Clone and return a new ReactElement using element as the starting point.
* See https://reactjs.org/docs/react-api.html#cloneelement
function cloneElement(element, config, children) {
if (element === null || element === undefined) {
throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
var propName; // Original props are copied
var props = assign({}, element.props); // Reserved names are extracted
var ref = element.ref; // Self is preserved since the owner is preserved.
var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
// transpiler, and the original source is probably a better indicator of the
var source = element._source; // Owner will be preserved, unless ref is overridden
var owner = element._owner;
if (hasValidRef(config)) {
// Silently steal the ref from the parent.
owner = ReactCurrentOwner.current;
if (hasValidKey(config)) {
checkKeyStringCoercion(config.key);
} // Remaining properties override existing props
if (element.type && element.type.defaultProps) {
defaultProps = element.type.defaultProps;
for (propName in config) {
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
if (config[propName] === undefined && defaultProps !== undefined) {
props[propName] = defaultProps[propName];
props[propName] = config[propName];
} // Children can be more than one argument, and those are transferred onto
// the newly allocated props object.
var childrenLength = arguments.length - 2;
if (childrenLength === 1) {
props.children = children;
} else if (childrenLength > 1) {
var childArray = Array(childrenLength);
for (var i = 0; i < childrenLength; i++) {
childArray[i] = arguments[i + 2];
props.children = childArray;
return ReactElement(element.type, key, ref, self, source, owner, props);
* Verifies the object is a ReactElement.
* See https://reactjs.org/docs/react-api.html#isvalidelement
* @param {?object} object
* @return {boolean} True if `object` is a ReactElement.
function isValidElement(object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
* Escape and wrap key so it is safe to use as a reactid
* @param {string} key to be escaped.
* @return {string} the escaped key.
var escapeRegex = /[=:]/g;
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
var didWarnAboutMaps = false;
var userProvidedKeyEscapeRegex = /\/+/g;
function escapeUserProvidedKey(text) {
return text.replace(userProvidedKeyEscapeRegex, '$&/');
* Generate a key string that identifies a element within a set.
* @param {*} element A element that could contain a manual key.
* @param {number} index Index that is used if a manual key is not provided.
function getElementKey(element, index) {
// Do some typechecking here since we call this blindly. We want to ensure
// that we don't block potential future ES APIs.
if (typeof element === 'object' && element !== null && element.key != null) {
checkKeyStringCoercion(element.key);
return escape('' + element.key);
} // Implicit key determined by the index in the set
return index.toString(36);
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
var type = typeof children;
if (type === 'undefined' || type === 'boolean') {
// All of the above are perceived as null.
var invokeCallback = false;
switch (children.$$typeof) {
var mappedChild = callback(_child); // 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:
var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
if (isArray(mappedChild)) {
var escapedChildKey = '';
escapedChildKey = escapeUserProvidedKey(childKey) + '/';
mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
} else if (mappedChild != null) {
if (isValidElement(mappedChild)) {
// The `if` statement here prevents auto-disabling of the safe
// coercion ESLint rule, so we must manually disable it below.
// $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
checkKeyStringCoercion(mappedChild.key);
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
// traverseAllChildren used to do for objects as children
escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
// eslint-disable-next-line react-internal/safe-string-coercion
escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);
var subtreeCount = 0; // Count of children found in the current subtree.
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
for (var i = 0; i < children.length; i++) {
nextName = nextNamePrefix + getElementKey(child, i);
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
var iteratorFn = getIteratorFn(children);
if (typeof iteratorFn === 'function') {
var iterableChildren = children;
// Warn about using Maps as children
if (iteratorFn === iterableChildren.entries) {
warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
var iterator = iteratorFn.call(iterableChildren);
while (!(step = iterator.next()).done) {
nextName = nextNamePrefix + getElementKey(child, ii++);
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
} else if (type === 'object') {
// eslint-disable-next-line react-internal/safe-string-coercion
var childrenString = String(children);
throw new Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
* Maps children that are typically specified as `props.children`.
* See https://reactjs.org/docs/react-api.html#reactchildrenmap
* The provided mapFunction(child, index) will be called for each
* @param {?*} children Children tree container.
* @param {function(*, int)} func The map function.
* @param {*} context Context for mapFunction.
* @return {object} Object containing the ordered map of results.
function mapChildren(children, func, context) {
mapIntoArray(children, result, '', '', function (child) {
return func.call(context, child, count++);
* Count the number of children that are typically specified as
* See https://reactjs.org/docs/react-api.html#reactchildrencount
* @param {?*} children Children tree container.
* @return {number} The number of children.
function countChildren(children) {
mapChildren(children, function () {
n++; // Don't return anything
* Iterates through children that are typically specified as `props.children`.
* See https://reactjs.org/docs/react-api.html#reactchildrenforeach
* The provided forEachFunc(child, index) will be called for each
* @param {?*} children Children tree container.
* @param {function(*, int)} forEachFunc
* @param {*} forEachContext Context for forEachContext.
function forEachChildren(children, forEachFunc, forEachContext) {
mapChildren(children, function () {
forEachFunc.apply(this, arguments); // Don't return anything.
* Flatten a children object (typically specified as `props.children`) and
* return an array with appropriately re-keyed children.
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
function toArray(children) {
return mapChildren(children, function (child) {
* Returns the first child in a collection of children and verifies that there
* is only one child in the collection.
* See https://reactjs.org/docs/react-api.html#reactchildrenonly
* 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
function onlyChild(children) {
if (!isValidElement(children)) {
throw new Error('React.Children.only expected to receive a single React element child.');
function createContext(defaultValue) {
// TODO: Second argument used to be an optional `calculateChangedBits`
// function. Warn to reserve for future use?
$$typeof: REACT_CONTEXT_TYPE,
// 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.
// Add these to use same hidden class in VM as ServerContext
$$typeof: REACT_PROVIDER_TYPE,
var hasWarnedAboutUsingNestedContextConsumers = false;
var hasWarnedAboutUsingConsumerProvider = false;
var hasWarnedAboutDisplayNameOnConsumer = 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.
$$typeof: REACT_CONTEXT_TYPE,
}; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
Object.defineProperties(Consumer, {
if (!hasWarnedAboutUsingConsumerProvider) {
hasWarnedAboutUsingConsumerProvider = true;
error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
set: function (_Provider) {
context.Provider = _Provider;
return context._currentValue;
set: function (_currentValue) {
context._currentValue = _currentValue;
return context._currentValue2;