From d319f4376fd23b96c4a25af2be3d3e5841826a01 Mon Sep 17 00:00:00 2001 From: gaearon Date: Wed, 21 Feb 2024 11:20:41 +0000 Subject: [PATCH] Remove JSX propTypes validation (#28328) This removes the remaining `propTypes` validation calls, making declaring `propTypes` a no-op. In other words, React itself will no longer validate the `propTypes` that you declare on your components. In general, our recommendation is to use static type checking (e.g. TypeScript). If you'd like to still run propTypes checks, you can do so manually, same as you'd do outside React: ```js import checkPropTypes from 'prop-types/checkPropTypes'; function Button(props) { checkPropTypes(Button.propTypes, prop, 'prop', Button.name) // ... } ``` This could be automated as a Babel plugin if you want to keep these checks implicit. (We will not be providing such a plugin, but someone in community might be interested in building or maintaining one.) DiffTrain build for [353ecd05160a318a3f75260ee7906fd12e05cb9d](https://github.com/facebook/react/commit/353ecd05160a318a3f75260ee7906fd12e05cb9d) --- .../facebook-www/JSXDEVRuntime-dev.classic.js | 172 ---------------- .../facebook-www/JSXDEVRuntime-dev.modern.js | 172 ---------------- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-dev.classic.js | 189 +----------------- compiled/facebook-www/React-dev.modern.js | 189 +----------------- compiled/facebook-www/React-prod.modern.js | 2 +- .../facebook-www/ReactServer-dev.modern.js | 189 +----------------- .../__test_utils__/ReactAllWarnings.js | 4 - 8 files changed, 23 insertions(+), 896 deletions(-) diff --git a/compiled/facebook-www/JSXDEVRuntime-dev.classic.js b/compiled/facebook-www/JSXDEVRuntime-dev.classic.js index 00689c901551e..deb98b9e19130 100644 --- a/compiled/facebook-www/JSXDEVRuntime-dev.classic.js +++ b/compiled/facebook-www/JSXDEVRuntime-dev.classic.js @@ -807,111 +807,6 @@ if (__DEV__) { return ""; } - var loggedTypeFailures = {}; - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function setCurrentlyValidatingElement$1(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } - } - } - - function checkPropTypes( - typeSpecs, - values, - location, - componentName, - element - ) { - { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - // eslint-disable-next-line react-internal/prod-error-codes - 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`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement$1(element); - - 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 - ); - - setCurrentlyValidatingElement$1(null); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement$1(element); - - error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement$1(null); - } - } - } - } - } - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); @@ -1314,8 +1209,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -1542,71 +1435,6 @@ if (__DEV__) { } } - var propTypesMisspellWarningShown = false; - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ - - function validatePropTypes(element) { - { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE) { - return; - } - - var propTypes; - - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } - - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown - ) { - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: - - var _name = getComponentNameFromType(type); - - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } - - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { - error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." - ); - } - } - } - var jsxDEV = jsxDEV$1; exports.Fragment = REACT_FRAGMENT_TYPE; diff --git a/compiled/facebook-www/JSXDEVRuntime-dev.modern.js b/compiled/facebook-www/JSXDEVRuntime-dev.modern.js index 2e152298c2869..f432bf9f90373 100644 --- a/compiled/facebook-www/JSXDEVRuntime-dev.modern.js +++ b/compiled/facebook-www/JSXDEVRuntime-dev.modern.js @@ -807,111 +807,6 @@ if (__DEV__) { return ""; } - var loggedTypeFailures = {}; - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function setCurrentlyValidatingElement$1(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } - } - } - - function checkPropTypes( - typeSpecs, - values, - location, - componentName, - element - ) { - { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - // eslint-disable-next-line react-internal/prod-error-codes - 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`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement$1(element); - - 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 - ); - - setCurrentlyValidatingElement$1(null); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement$1(element); - - error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement$1(null); - } - } - } - } - } - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); @@ -1314,8 +1209,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -1542,71 +1435,6 @@ if (__DEV__) { } } - var propTypesMisspellWarningShown = false; - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ - - function validatePropTypes(element) { - { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE) { - return; - } - - var propTypes; - - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } - - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown - ) { - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: - - var _name = getComponentNameFromType(type); - - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } - - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { - error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." - ); - } - } - } - var jsxDEV = jsxDEV$1; exports.Fragment = REACT_FRAGMENT_TYPE; diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 7134b36ed3c96..73cd7c4dc9212 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -4ea424e63d1a74ce57ef675b64a8c4eabfdb2fdc +353ecd05160a318a3f75260ee7906fd12e05cb9d diff --git a/compiled/facebook-www/React-dev.classic.js b/compiled/facebook-www/React-dev.classic.js index 9c01e1e2162b8..f8bd6b8831938 100644 --- a/compiled/facebook-www/React-dev.classic.js +++ b/compiled/facebook-www/React-dev.classic.js @@ -24,7 +24,7 @@ if (__DEV__) { ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = "18.3.0-www-classic-57c8bbe5"; + var ReactVersion = "18.3.0-www-classic-3f51e0fb"; // ATTENTION // When adding new symbols to this file, @@ -662,26 +662,26 @@ if (__DEV__) { current: null }; - var ReactDebugCurrentFrame$2 = {}; + var ReactDebugCurrentFrame$1 = {}; var currentExtraStackFrame = null; { - ReactDebugCurrentFrame$2.setExtraStackFrame = function (stack) { + ReactDebugCurrentFrame$1.setExtraStackFrame = function (stack) { { currentExtraStackFrame = stack; } }; // Stack implementation injected by the current renderer. - ReactDebugCurrentFrame$2.getCurrentStack = null; + ReactDebugCurrentFrame$1.getCurrentStack = null; - ReactDebugCurrentFrame$2.getStackAddendum = function () { + ReactDebugCurrentFrame$1.getStackAddendum = function () { var stack = ""; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) { stack += currentExtraStackFrame; } // Delegate to the injected renderer-specific implementation - var impl = ReactDebugCurrentFrame$2.getCurrentStack; + var impl = ReactDebugCurrentFrame$1.getCurrentStack; if (impl) { stack += impl() || ""; @@ -699,7 +699,7 @@ if (__DEV__) { }; { - ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$2; + ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$1; ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue; } @@ -1179,111 +1179,6 @@ if (__DEV__) { return ""; } - var loggedTypeFailures = {}; - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function setCurrentlyValidatingElement$1(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } - } - } - - function checkPropTypes( - typeSpecs, - values, - location, - componentName, - element - ) { - { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - // eslint-disable-next-line react-internal/prod-error-codes - 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`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement$1(element); - - 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 - ); - - setCurrentlyValidatingElement$1(null); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement$1(element); - - error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement$1(null); - } - } - } - } - } - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); @@ -1722,8 +1617,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -1901,8 +1794,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -2065,7 +1956,6 @@ if (__DEV__) { validateChildKeys(arguments[_i2], clonedElement.type); } - validatePropTypes(clonedElement); return clonedElement; } @@ -2297,71 +2187,6 @@ if (__DEV__) { } } - var propTypesMisspellWarningShown = false; - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ - - function validatePropTypes(element) { - { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE) { - return; - } - - var propTypes; - - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } - - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown - ) { - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: - - var _name = getComponentNameFromType(type); - - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } - - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { - error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." - ); - } - } - } - var SEPARATOR = "."; var SUBSEPARATOR = ":"; /** diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index 0e5c090ecc31c..a28d3952d97f4 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -24,7 +24,7 @@ if (__DEV__) { ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = "18.3.0-www-modern-e08a9866"; + var ReactVersion = "18.3.0-www-modern-5e309987"; // ATTENTION // When adding new symbols to this file, @@ -662,26 +662,26 @@ if (__DEV__) { current: null }; - var ReactDebugCurrentFrame$2 = {}; + var ReactDebugCurrentFrame$1 = {}; var currentExtraStackFrame = null; { - ReactDebugCurrentFrame$2.setExtraStackFrame = function (stack) { + ReactDebugCurrentFrame$1.setExtraStackFrame = function (stack) { { currentExtraStackFrame = stack; } }; // Stack implementation injected by the current renderer. - ReactDebugCurrentFrame$2.getCurrentStack = null; + ReactDebugCurrentFrame$1.getCurrentStack = null; - ReactDebugCurrentFrame$2.getStackAddendum = function () { + ReactDebugCurrentFrame$1.getStackAddendum = function () { var stack = ""; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) { stack += currentExtraStackFrame; } // Delegate to the injected renderer-specific implementation - var impl = ReactDebugCurrentFrame$2.getCurrentStack; + var impl = ReactDebugCurrentFrame$1.getCurrentStack; if (impl) { stack += impl() || ""; @@ -699,7 +699,7 @@ if (__DEV__) { }; { - ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$2; + ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$1; ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue; } @@ -1179,111 +1179,6 @@ if (__DEV__) { return ""; } - var loggedTypeFailures = {}; - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function setCurrentlyValidatingElement$1(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } - } - } - - function checkPropTypes( - typeSpecs, - values, - location, - componentName, - element - ) { - { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - // eslint-disable-next-line react-internal/prod-error-codes - 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`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement$1(element); - - 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 - ); - - setCurrentlyValidatingElement$1(null); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement$1(element); - - error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement$1(null); - } - } - } - } - } - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); @@ -1722,8 +1617,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -1901,8 +1794,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -2021,7 +1912,6 @@ if (__DEV__) { validateChildKeys(arguments[_i2], clonedElement.type); } - validatePropTypes(clonedElement); return clonedElement; } @@ -2253,71 +2143,6 @@ if (__DEV__) { } } - var propTypesMisspellWarningShown = false; - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ - - function validatePropTypes(element) { - { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE) { - return; - } - - var propTypes; - - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } - - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown - ) { - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: - - var _name = getComponentNameFromType(type); - - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } - - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { - error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." - ); - } - } - } - var SEPARATOR = "."; var SUBSEPARATOR = ":"; /** diff --git a/compiled/facebook-www/React-prod.modern.js b/compiled/facebook-www/React-prod.modern.js index 459b7b8da336f..c1113c80ec70d 100644 --- a/compiled/facebook-www/React-prod.modern.js +++ b/compiled/facebook-www/React-prod.modern.js @@ -620,4 +620,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "18.3.0-www-modern-1627727c"; +exports.version = "18.3.0-www-modern-e57a04c5"; diff --git a/compiled/facebook-www/ReactServer-dev.modern.js b/compiled/facebook-www/ReactServer-dev.modern.js index cc4cc71576f9f..30d7af9a98ae5 100644 --- a/compiled/facebook-www/ReactServer-dev.modern.js +++ b/compiled/facebook-www/ReactServer-dev.modern.js @@ -118,26 +118,26 @@ if (__DEV__) { current: null }; - var ReactDebugCurrentFrame$2 = {}; + var ReactDebugCurrentFrame$1 = {}; var currentExtraStackFrame = null; { - ReactDebugCurrentFrame$2.setExtraStackFrame = function (stack) { + ReactDebugCurrentFrame$1.setExtraStackFrame = function (stack) { { currentExtraStackFrame = stack; } }; // Stack implementation injected by the current renderer. - ReactDebugCurrentFrame$2.getCurrentStack = null; + ReactDebugCurrentFrame$1.getCurrentStack = null; - ReactDebugCurrentFrame$2.getStackAddendum = function () { + ReactDebugCurrentFrame$1.getStackAddendum = function () { var stack = ""; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) { stack += currentExtraStackFrame; } // Delegate to the injected renderer-specific implementation - var impl = ReactDebugCurrentFrame$2.getCurrentStack; + var impl = ReactDebugCurrentFrame$1.getCurrentStack; if (impl) { stack += impl() || ""; @@ -153,7 +153,7 @@ if (__DEV__) { }; { - ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$2; + ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame$1; } var ReactServerSharedInternals = { @@ -892,111 +892,6 @@ if (__DEV__) { return ""; } - var loggedTypeFailures = {}; - var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; - - function setCurrentlyValidatingElement$1(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - owner ? owner.type : null - ); - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame$1.setExtraStackFrame(null); - } - } - } - - function checkPropTypes( - typeSpecs, - values, - location, - componentName, - element - ) { - { - // $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it. - var has = Function.call.bind(hasOwnProperty); - - for (var typeSpecName in typeSpecs) { - if (has(typeSpecs, typeSpecName)) { - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== "function") { - // eslint-disable-next-line react-internal/prod-error-codes - 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`." - ); - err.name = "Invariant Violation"; - throw err; - } - - error$1 = typeSpecs[typeSpecName]( - values, - typeSpecName, - componentName, - location, - null, - "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" - ); - } catch (ex) { - error$1 = ex; - } - - if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement$1(element); - - 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 - ); - - setCurrentlyValidatingElement$1(null); - } - - if ( - error$1 instanceof Error && - !(error$1.message in loggedTypeFailures) - ) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement$1(element); - - error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement$1(null); - } - } - } - } - } - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); @@ -1435,8 +1330,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -1614,8 +1507,6 @@ if (__DEV__) { if (type === REACT_FRAGMENT_TYPE) { validateFragmentProps(element); - } else { - validatePropTypes(element); } return element; @@ -1734,7 +1625,6 @@ if (__DEV__) { validateChildKeys(arguments[_i2], clonedElement.type); } - validatePropTypes(clonedElement); return clonedElement; } @@ -1966,71 +1856,6 @@ if (__DEV__) { } } - var propTypesMisspellWarningShown = false; - /** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ - - function validatePropTypes(element) { - { - var type = element.type; - - if (type === null || type === undefined || typeof type === "string") { - return; - } - - if (type.$$typeof === REACT_CLIENT_REFERENCE) { - return; - } - - var propTypes; - - if (typeof type === "function") { - propTypes = type.propTypes; - } else if ( - typeof type === "object" && - (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE) - ) { - propTypes = type.propTypes; - } else { - return; - } - - if (propTypes) { - // Intentionally inside to avoid triggering lazy initializers: - var name = getComponentNameFromType(type); - checkPropTypes(propTypes, element.props, "prop", name, element); - } else if ( - type.PropTypes !== undefined && - !propTypesMisspellWarningShown - ) { - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: - - var _name = getComponentNameFromType(type); - - error( - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", - _name || "Unknown" - ); - } - - if ( - typeof type.getDefaultProps === "function" && - !type.getDefaultProps.isReactClassApproved - ) { - error( - "getDefaultProps is only used on classic React.createClass " + - "definitions. Use a static property named `defaultProps` instead." - ); - } - } - } - var SEPARATOR = "."; var SUBSEPARATOR = ":"; /** @@ -2941,7 +2766,7 @@ if (__DEV__) { console["error"](error); }; - var ReactVersion = "18.3.0-www-modern-d6a3bd7a"; + var ReactVersion = "18.3.0-www-modern-c52425e5"; // Patch fetch var Children = { diff --git a/compiled/facebook-www/__test_utils__/ReactAllWarnings.js b/compiled/facebook-www/__test_utils__/ReactAllWarnings.js index 663366142c91d..5d4d5526a2473 100644 --- a/compiled/facebook-www/__test_utils__/ReactAllWarnings.js +++ b/compiled/facebook-www/__test_utils__/ReactAllWarnings.js @@ -68,7 +68,6 @@ export default [ "%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.", "%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.", "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.", - "%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).", "<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.", " is only valid if revealOrder is \"forwards\" or \"backwards\". Did you mean to specify revealOrder=\"forwards\"?", "A button can only specify a formAction along with type=\"submit\" or no type.", @@ -133,7 +132,6 @@ export default [ "Changing the name of a tracing marker after mount is not supported. To remount the tracing marker, pass it a new key.", "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: https://reactjs.org/link/strict-mode-string-ref", "Component \"%s\" contains the string ref \"%s\". Support for string refs will be removed in a future major release. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref", - "Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().", "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.", "Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.", @@ -177,7 +175,6 @@ export default [ "Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", "Extra attributes from the server: %s", "Factory.type is deprecated. Access the class directly before passing it to createFactory.", - "Failed %s type: %s", "Form field values (value, checked, defaultValue, or defaultChecked props) must be strings, not %s. This value must be coerced to a string before using it here.", "Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s", "Functions are not valid as a React child. This may happen if you return %s instead of <%s /> from render. Or maybe you meant to call this function rather than return it.", @@ -381,7 +378,6 @@ export default [ "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?", "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).", "forwardRef requires a render function but was given %s.", - "getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.", "getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.", "getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?", "getInspectorDataForViewAtPoint expects to receive a host component",