From 120239fa77c5bfb4954f56d01ac85b90f741e18a Mon Sep 17 00:00:00 2001 From: kassens Date: Fri, 29 Mar 2024 20:34:34 +0000 Subject: [PATCH] Remove React.createFactory (#27798) `React.createFactory` has been long deprecated. This removes it for the next release. DiffTrain build for [2aed507a76a0b1524426c398897cbe47d80c51e5](https://github.com/facebook/react/commit/2aed507a76a0b1524426c398897cbe47d80c51e5) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-dev.classic.js | 47 +---------- compiled/facebook-www/React-prod.classic.js | 82 +++++++++---------- .../facebook-www/React-profiling.classic.js | 82 +++++++++---------- .../__test_utils__/ReactAllWarnings.js | 2 - 5 files changed, 78 insertions(+), 137 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index f907ac182da71..afa293becc5e6 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -6cd6ba703de77e332ab201518b6e30e47cd49aaf +2aed507a76a0b1524426c398897cbe47d80c51e5 diff --git a/compiled/facebook-www/React-dev.classic.js b/compiled/facebook-www/React-dev.classic.js index 64f6a4f9ed475..9d8780f1f9d22 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 = "19.0.0-www-classic-8c9925ed"; + var ReactVersion = "19.0.0-www-classic-83a7d6d7"; // ATTENTION // When adding new symbols to this file, @@ -1858,50 +1858,6 @@ if (__DEV__) { return element; } - var didWarnAboutDeprecatedCreateFactory = false; - /** - * Return a function that produces ReactElements of a given type. - * See https://reactjs.org/docs/react-api.html#createfactory - */ - - function createFactory(type) { - var factory = createElement.bind(null, type); // Expose the type on the factory and the prototype so that it can be - // easily accessed on elements. E.g. `.type === Foo`. - // This should not be named `constructor` since this may not be the function - // that created the element, and it may not even be a constructor. - // Legacy hook: remove it - - factory.type = type; - - { - if (!didWarnAboutDeprecatedCreateFactory) { - didWarnAboutDeprecatedCreateFactory = true; - - warn( - "React.createFactory() is deprecated and will be removed in " + - "a future major release. Consider using JSX " + - "or use React.createElement() directly instead." - ); - } // Legacy hook: remove it - - Object.defineProperty(factory, "type", { - enumerable: false, - get: function () { - warn( - "Factory.type is deprecated. Access the class directly " + - "before passing it to createFactory." - ); - - Object.defineProperty(this, "type", { - value: type - }); - return type; - } - }); - } - - return factory; - } function cloneAndReplaceKey(oldElement, newKey) { return ReactElement( oldElement.type, @@ -3704,7 +3660,6 @@ if (__DEV__) { exports.cloneElement = cloneElement; exports.createContext = createContext; exports.createElement = createElement; - exports.createFactory = createFactory; exports.createRef = createRef; exports.experimental_useEffectEvent = useEffectEvent; exports.forwardRef = forwardRef; diff --git a/compiled/facebook-www/React-prod.classic.js b/compiled/facebook-www/React-prod.classic.js index 7eea305f471a0..fb30a87f27f8b 100644 --- a/compiled/facebook-www/React-prod.classic.js +++ b/compiled/facebook-www/React-prod.classic.js @@ -136,44 +136,6 @@ function jsxProd(type, config, maybeKey) { props ); } -function createElement(type, config, children) { - var propName, - props = {}, - key = null, - ref = null; - if (null != config) - for (propName in (void 0 === config.ref || - enableRefAsProp || - (ref = config.ref), - void 0 !== config.key && (key = "" + config.key), - config)) - hasOwnProperty.call(config, propName) && - "key" !== propName && - (enableRefAsProp || "ref" !== propName) && - "__self" !== propName && - "__source" !== propName && - (props[propName] = config[propName]); - var childrenLength = arguments.length - 2; - if (1 === childrenLength) props.children = children; - else if (1 < childrenLength) { - for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) - childArray[i] = arguments[i + 2]; - props.children = childArray; - } - if (type && type.defaultProps) - for (propName in ((childrenLength = type.defaultProps), childrenLength)) - void 0 === props[propName] && - (props[propName] = childrenLength[propName]); - return ReactElement( - type, - key, - ref, - void 0, - void 0, - ReactCurrentOwner.current, - props - ); -} function cloneAndReplaceKey(oldElement, newKey) { return ReactElement( oldElement.type, @@ -515,11 +477,43 @@ exports.createContext = function (defaultValue) { (defaultValue.Consumer = defaultValue)); return defaultValue; }; -exports.createElement = createElement; -exports.createFactory = function (type) { - var factory = createElement.bind(null, type); - factory.type = type; - return factory; +exports.createElement = function (type, config, children) { + var propName, + props = {}, + key = null, + ref = null; + if (null != config) + for (propName in (void 0 === config.ref || + enableRefAsProp || + (ref = config.ref), + void 0 !== config.key && (key = "" + config.key), + config)) + hasOwnProperty.call(config, propName) && + "key" !== propName && + (enableRefAsProp || "ref" !== propName) && + "__self" !== propName && + "__source" !== propName && + (props[propName] = config[propName]); + var childrenLength = arguments.length - 2; + if (1 === childrenLength) props.children = children; + else if (1 < childrenLength) { + for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) + childArray[i] = arguments[i + 2]; + props.children = childArray; + } + if (type && type.defaultProps) + for (propName in ((childrenLength = type.defaultProps), childrenLength)) + void 0 === props[propName] && + (props[propName] = childrenLength[propName]); + return ReactElement( + type, + key, + ref, + void 0, + void 0, + ReactCurrentOwner.current, + props + ); }; exports.createRef = function () { return { current: null }; @@ -666,4 +660,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "19.0.0-www-classic-53088215"; +exports.version = "19.0.0-www-classic-b1e9d190"; diff --git a/compiled/facebook-www/React-profiling.classic.js b/compiled/facebook-www/React-profiling.classic.js index 0e3a6d692fbfe..6001a1f2cc519 100644 --- a/compiled/facebook-www/React-profiling.classic.js +++ b/compiled/facebook-www/React-profiling.classic.js @@ -140,44 +140,6 @@ function jsxProd(type, config, maybeKey) { props ); } -function createElement(type, config, children) { - var propName, - props = {}, - key = null, - ref = null; - if (null != config) - for (propName in (void 0 === config.ref || - enableRefAsProp || - (ref = config.ref), - void 0 !== config.key && (key = "" + config.key), - config)) - hasOwnProperty.call(config, propName) && - "key" !== propName && - (enableRefAsProp || "ref" !== propName) && - "__self" !== propName && - "__source" !== propName && - (props[propName] = config[propName]); - var childrenLength = arguments.length - 2; - if (1 === childrenLength) props.children = children; - else if (1 < childrenLength) { - for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) - childArray[i] = arguments[i + 2]; - props.children = childArray; - } - if (type && type.defaultProps) - for (propName in ((childrenLength = type.defaultProps), childrenLength)) - void 0 === props[propName] && - (props[propName] = childrenLength[propName]); - return ReactElement( - type, - key, - ref, - void 0, - void 0, - ReactCurrentOwner.current, - props - ); -} function cloneAndReplaceKey(oldElement, newKey) { return ReactElement( oldElement.type, @@ -519,11 +481,43 @@ exports.createContext = function (defaultValue) { (defaultValue.Consumer = defaultValue)); return defaultValue; }; -exports.createElement = createElement; -exports.createFactory = function (type) { - var factory = createElement.bind(null, type); - factory.type = type; - return factory; +exports.createElement = function (type, config, children) { + var propName, + props = {}, + key = null, + ref = null; + if (null != config) + for (propName in (void 0 === config.ref || + enableRefAsProp || + (ref = config.ref), + void 0 !== config.key && (key = "" + config.key), + config)) + hasOwnProperty.call(config, propName) && + "key" !== propName && + (enableRefAsProp || "ref" !== propName) && + "__self" !== propName && + "__source" !== propName && + (props[propName] = config[propName]); + var childrenLength = arguments.length - 2; + if (1 === childrenLength) props.children = children; + else if (1 < childrenLength) { + for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) + childArray[i] = arguments[i + 2]; + props.children = childArray; + } + if (type && type.defaultProps) + for (propName in ((childrenLength = type.defaultProps), childrenLength)) + void 0 === props[propName] && + (props[propName] = childrenLength[propName]); + return ReactElement( + type, + key, + ref, + void 0, + void 0, + ReactCurrentOwner.current, + props + ); }; exports.createRef = function () { return { current: null }; @@ -670,7 +664,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactCurrentDispatcher.current.useTransition(); }; -exports.version = "19.0.0-www-classic-15c65c77"; +exports.version = "19.0.0-www-classic-7ee6e970"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/__test_utils__/ReactAllWarnings.js b/compiled/facebook-www/__test_utils__/ReactAllWarnings.js index 86ad229eb3b60..16031ebe77752 100644 --- a/compiled/facebook-www/__test_utils__/ReactAllWarnings.js +++ b/compiled/facebook-www/__test_utils__/ReactAllWarnings.js @@ -158,7 +158,6 @@ export default [ "Expected to find the propagation root when scheduling context work. This error is likely caused by a bug in React. Please file an issue.", "Expected useImperativeHandle() first argument to either be a ref callback or React.createRef() object. Instead received: %s.", "Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", - "Factory.type is deprecated. Access the class directly before passing it to createFactory.", "Failed to serialize an action for progressive enhancement:\n%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", @@ -232,7 +231,6 @@ export default [ "React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React.", "React was unable to patch the fetch() function in this environment. Suspensey APIs might not work correctly as a result.", "React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - "React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.", "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.", "React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",