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 commit 2aed507.
  • Loading branch information
kassens committed Mar 29, 2024
1 parent 2eb1b51 commit 1cfd770
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<ba8e03c28352119146c3eb29b5683ded>>
* @generated SignedSource<<3c9d3cbcbb7690bdd3c319e0ba24e0a8>>
*/

"use strict";
Expand All @@ -26,7 +26,7 @@ if (__DEV__) {
}
var dynamicFlagsUntyped = require("ReactNativeInternalFeatureFlags");

var ReactVersion = "19.0.0-canary-66632b76";
var ReactVersion = "19.0.0-canary-d53f813c";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -1825,50 +1825,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 @@ -3673,7 +3629,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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<ac6e1c721cd9e734454c18870d36b509>>
* @generated SignedSource<<ed4da00dc7705121a507bffa64d7f8bb>>
*/

"use strict";
Expand Down Expand Up @@ -133,42 +133,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 && (ref = config.ref),
void 0 !== config.key && (key = "" + config.key),
config))
hasOwnProperty.call(config, propName) &&
"key" !== propName &&
"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 @@ -508,11 +472,41 @@ 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 && (ref = config.ref),
void 0 !== config.key && (key = "" + config.key),
config))
hasOwnProperty.call(config, propName) &&
"key" !== propName &&
"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 @@ -663,4 +657,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "19.0.0-canary-bd294150";
exports.version = "19.0.0-canary-a9f85346";
Original file line number Diff line number Diff line change
@@ -1 +1 @@
425f72bdd4263dcaba829cf52545309bbfde56b4
2aed507a76a0b1524426c398897cbe47d80c51e5

0 comments on commit 1cfd770

Please sign in to comment.