Remove React.createFactory (#27798)

`React.createFactory` has been long deprecated. This removes it for the
next release.

DiffTrain build for [2aed507a76](https://github.com/facebook/react/commit/2aed507a76a0b1524426c398897cbe47d80c51e5)
This commit is contained in:
kassens
2024-03-29 20:34:34 +00:00
parent 2d29da831d
commit 120239fa77
5 changed files with 78 additions and 137 deletions
+1 -1
View File
@@ -1 +1 @@
6cd6ba703de77e332ab201518b6e30e47cd49aaf
2aed507a76a0b1524426c398897cbe47d80c51e5
+1 -46
View File
@@ -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. `<Foo />.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;
+38 -44
View File
@@ -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";
@@ -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 &&
@@ -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.",