Skip to content

Commit

Permalink
Remove React.createFactory (#27798)
Browse files Browse the repository at this point in the history
`React.createFactory` has been long deprecated. This removes it for the
next release.

DiffTrain build for [2aed507](2aed507)
  • Loading branch information
kassens committed Mar 29, 2024
1 parent 2d29da8 commit 120239f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 137 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6cd6ba703de77e332ab201518b6e30e47cd49aaf
2aed507a76a0b1524426c398897cbe47d80c51e5
47 changes: 1 addition & 46 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
82 changes: 38 additions & 44 deletions compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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";
82 changes: 38 additions & 44 deletions compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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 &&
Expand Down
2 changes: 0 additions & 2 deletions compiled/facebook-www/__test_utils__/ReactAllWarnings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 120239f

Please sign in to comment.