diff --git a/packages/react/src/ReactElement.js b/packages/react/src/ReactElement.js index a2914b78fc221..a0bfd0d551691 100644 --- a/packages/react/src/ReactElement.js +++ b/packages/react/src/ReactElement.js @@ -22,26 +22,10 @@ const RESERVED_PROPS = { let specialPropKeyWarningShown, specialPropRefWarningShown; function hasValidRef(config) { - if (__DEV__) { - if (hasOwnProperty.call(config, 'ref')) { - const getter = Object.getOwnPropertyDescriptor(config, 'ref').get; - if (getter && getter.isReactWarning) { - return false; - } - } - } return config.ref !== undefined; } function hasValidKey(config) { - if (__DEV__) { - if (hasOwnProperty.call(config, 'key')) { - const getter = Object.getOwnPropertyDescriptor(config, 'key').get; - if (getter && getter.isReactWarning) { - return false; - } - } - } return config.key !== undefined; } @@ -121,45 +105,6 @@ const ReactElement = function(type, key, ref, self, source, owner, props) { // Record the component responsible for creating this element. _owner: owner, }; - - if (__DEV__) { - // 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. - Object.defineProperty(element._store, 'validated', { - configurable: false, - enumerable: false, - writable: true, - value: false, - }); - // self and source are DEV only properties. - Object.defineProperty(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. - Object.defineProperty(element, '_source', { - configurable: false, - enumerable: false, - writable: false, - value: source, - }); - if (Object.freeze) { - Object.freeze(element.props); - Object.freeze(element); - } - } - return element; }; @@ -209,11 +154,6 @@ export function createElement(type, config, children) { for (let i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } - if (__DEV__) { - if (Object.freeze) { - Object.freeze(childArray); - } - } props.children = childArray; } @@ -226,25 +166,6 @@ export function createElement(type, config, children) { } } } - if (__DEV__) { - if (key || ref) { - if ( - typeof props.$$typeof === 'undefined' || - props.$$typeof !== REACT_ELEMENT_TYPE - ) { - const displayName = - typeof type === 'function' - ? type.displayName || type.name || 'Unknown' - : type; - if (key) { - defineKeyPropWarningGetter(props, displayName); - } - if (ref) { - defineRefPropWarningGetter(props, displayName); - } - } - } - } return ReactElement( type, key,