Skip to content

Commit

Permalink
Remove module pattern function component support (flag only) (#28671)
Browse files Browse the repository at this point in the history
Remove module pattern function component support (flag only)

> This is a redo of #27742, but only including the flag removal,
excluding further simplifications.

The module pattern

```
function MyComponent() {
  return {
    render() {
      return this.state.foo
    }
  }
}
```

has been deprecated for approximately 5 years now. This PR removes
support for this pattern.

DiffTrain build for [a73c345](a73c345)
  • Loading branch information
kassens committed Mar 29, 2024
1 parent 87edb8c commit 9f9e660
Show file tree
Hide file tree
Showing 20 changed files with 302 additions and 345 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f2690747239533fa266612d2d4dd9ae88ea92fbc
a73c3450e1b528fa6cb3e94fa4d4359c7a4b61f1
43 changes: 20 additions & 23 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "19.0.0-www-classic-3513bb8c";
var ReactVersion = "19.0.0-www-classic-b7bec335";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -16812,20 +16812,17 @@ if (__DEV__) {
didWarnAboutModulePatternComponent[_componentName] = true;
}
}
}

{
// Proceed under the assumption that this is a function component
workInProgress.tag = FunctionComponent;
} // Proceed under the assumption that this is a function component

reconcileChildren(null, workInProgress, value, renderLanes);
workInProgress.tag = FunctionComponent;

{
validateFunctionComponentInDev(workInProgress, Component);
}
reconcileChildren(null, workInProgress, value, renderLanes);

return workInProgress.child;
{
validateFunctionComponentInDev(workInProgress, Component);
}

return workInProgress.child;
}

function validateFunctionComponentInDev(workInProgress, Component) {
Expand Down Expand Up @@ -16864,33 +16861,33 @@ if (__DEV__) {
}

if (Component.defaultProps !== undefined) {
var _componentName3 =
var _componentName2 =
getComponentNameFromType(Component) || "Unknown";

if (!didWarnAboutDefaultPropsOnFunctionComponent[_componentName3]) {
if (!didWarnAboutDefaultPropsOnFunctionComponent[_componentName2]) {
error(
"%s: Support for defaultProps will be removed from function components " +
"in a future major release. Use JavaScript default parameters instead.",
_componentName3
_componentName2
);

didWarnAboutDefaultPropsOnFunctionComponent[_componentName3] = true;
didWarnAboutDefaultPropsOnFunctionComponent[_componentName2] = true;
}
}

if (typeof Component.getDerivedStateFromProps === "function") {
var _componentName4 =
var _componentName3 =
getComponentNameFromType(Component) || "Unknown";

if (
!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName4]
!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]
) {
error(
"%s: Function components do not support getDerivedStateFromProps.",
_componentName4
_componentName3
);

didWarnAboutGetDerivedStateOnFunctionComponent[_componentName4] =
didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] =
true;
}
}
Expand All @@ -16899,16 +16896,16 @@ if (__DEV__) {
typeof Component.contextType === "object" &&
Component.contextType !== null
) {
var _componentName5 =
var _componentName4 =
getComponentNameFromType(Component) || "Unknown";

if (!didWarnAboutContextTypeOnFunctionComponent[_componentName5]) {
if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
error(
"%s: Function components do not support contextType.",
_componentName5
_componentName4
);

didWarnAboutContextTypeOnFunctionComponent[_componentName5] = true;
didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
}
}
}
Expand Down
59 changes: 28 additions & 31 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "19.0.0-www-modern-6b2eae4e";
var ReactVersion = "19.0.0-www-modern-210281fd";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -16496,30 +16496,27 @@ if (__DEV__) {
didWarnAboutModulePatternComponent[_componentName] = true;
}
}
}
} // Proceed under the assumption that this is a function component

{
// Proceed under the assumption that this is a function component
workInProgress.tag = FunctionComponent;
workInProgress.tag = FunctionComponent;

{
if (Component.contextTypes) {
error(
"%s uses the legacy contextTypes API which was removed in React 19. " +
"Use React.createContext() with React.useContext() instead.",
getComponentNameFromType(Component) || "Unknown"
);
}
{
if (Component.contextTypes) {
error(
"%s uses the legacy contextTypes API which was removed in React 19. " +
"Use React.createContext() with React.useContext() instead.",
getComponentNameFromType(Component) || "Unknown"
);
}
}

reconcileChildren(null, workInProgress, value, renderLanes);
reconcileChildren(null, workInProgress, value, renderLanes);

{
validateFunctionComponentInDev(workInProgress, Component);
}

return workInProgress.child;
{
validateFunctionComponentInDev(workInProgress, Component);
}

return workInProgress.child;
}

function validateFunctionComponentInDev(workInProgress, Component) {
Expand Down Expand Up @@ -16558,33 +16555,33 @@ if (__DEV__) {
}

if (Component.defaultProps !== undefined) {
var _componentName3 =
var _componentName2 =
getComponentNameFromType(Component) || "Unknown";

if (!didWarnAboutDefaultPropsOnFunctionComponent[_componentName3]) {
if (!didWarnAboutDefaultPropsOnFunctionComponent[_componentName2]) {
error(
"%s: Support for defaultProps will be removed from function components " +
"in a future major release. Use JavaScript default parameters instead.",
_componentName3
_componentName2
);

didWarnAboutDefaultPropsOnFunctionComponent[_componentName3] = true;
didWarnAboutDefaultPropsOnFunctionComponent[_componentName2] = true;
}
}

if (typeof Component.getDerivedStateFromProps === "function") {
var _componentName4 =
var _componentName3 =
getComponentNameFromType(Component) || "Unknown";

if (
!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName4]
!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]
) {
error(
"%s: Function components do not support getDerivedStateFromProps.",
_componentName4
_componentName3
);

didWarnAboutGetDerivedStateOnFunctionComponent[_componentName4] =
didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] =
true;
}
}
Expand All @@ -16593,16 +16590,16 @@ if (__DEV__) {
typeof Component.contextType === "object" &&
Component.contextType !== null
) {
var _componentName5 =
var _componentName4 =
getComponentNameFromType(Component) || "Unknown";

if (!didWarnAboutContextTypeOnFunctionComponent[_componentName5]) {
if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
error(
"%s: Function components do not support contextType.",
_componentName5
_componentName4
);

didWarnAboutContextTypeOnFunctionComponent[_componentName5] = true;
didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5633,8 +5633,7 @@ function beginWork(current, workInProgress, renderLanes) {
workInProgress.flags |= 1;
workInProgress.tag = 0;
reconcileChildren(null, workInProgress, current, renderLanes);
workInProgress = workInProgress.child;
return workInProgress;
return workInProgress.child;
case 16:
Component = workInProgress.elementType;
a: {
Expand Down Expand Up @@ -10617,7 +10616,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-classic-1ca45163",
version: "19.0.0-www-classic-03341623",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1324 = {
Expand Down Expand Up @@ -10648,7 +10647,7 @@ var internals$jscomp$inline_1324 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-1ca45163"
reconcilerVersion: "19.0.0-www-classic-03341623"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1325 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
7 changes: 3 additions & 4 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -5371,8 +5371,7 @@ function beginWork(current, workInProgress, renderLanes) {
workInProgress.flags |= 1;
workInProgress.tag = 0;
reconcileChildren(null, workInProgress, current, renderLanes);
workInProgress = workInProgress.child;
return workInProgress;
return workInProgress.child;
case 16:
Component = workInProgress.elementType;
a: {
Expand Down Expand Up @@ -10272,7 +10271,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "19.0.0-www-modern-ba56ad23",
version: "19.0.0-www-modern-672a54bb",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1304 = {
Expand Down Expand Up @@ -10303,7 +10302,7 @@ var internals$jscomp$inline_1304 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-ba56ad23"
reconcilerVersion: "19.0.0-www-modern-672a54bb"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1305 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
49 changes: 23 additions & 26 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -21796,24 +21796,21 @@ if (__DEV__) {
didWarnAboutModulePatternComponent[_componentName] = true;
}
}
}
} // Proceed under the assumption that this is a function component

{
// Proceed under the assumption that this is a function component
workInProgress.tag = FunctionComponent;
workInProgress.tag = FunctionComponent;

if (getIsHydrating() && hasId) {
pushMaterializedTreeId(workInProgress);
}

reconcileChildren(null, workInProgress, value, renderLanes);
if (getIsHydrating() && hasId) {
pushMaterializedTreeId(workInProgress);
}

{
validateFunctionComponentInDev(workInProgress, Component);
}
reconcileChildren(null, workInProgress, value, renderLanes);

return workInProgress.child;
{
validateFunctionComponentInDev(workInProgress, Component);
}

return workInProgress.child;
}

function validateFunctionComponentInDev(workInProgress, Component) {
Expand Down Expand Up @@ -21852,33 +21849,33 @@ if (__DEV__) {
}

if (Component.defaultProps !== undefined) {
var _componentName3 =
var _componentName2 =
getComponentNameFromType(Component) || "Unknown";

if (!didWarnAboutDefaultPropsOnFunctionComponent[_componentName3]) {
if (!didWarnAboutDefaultPropsOnFunctionComponent[_componentName2]) {
error(
"%s: Support for defaultProps will be removed from function components " +
"in a future major release. Use JavaScript default parameters instead.",
_componentName3
_componentName2
);

didWarnAboutDefaultPropsOnFunctionComponent[_componentName3] = true;
didWarnAboutDefaultPropsOnFunctionComponent[_componentName2] = true;
}
}

if (typeof Component.getDerivedStateFromProps === "function") {
var _componentName4 =
var _componentName3 =
getComponentNameFromType(Component) || "Unknown";

if (
!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName4]
!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]
) {
error(
"%s: Function components do not support getDerivedStateFromProps.",
_componentName4
_componentName3
);

didWarnAboutGetDerivedStateOnFunctionComponent[_componentName4] =
didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] =
true;
}
}
Expand All @@ -21887,16 +21884,16 @@ if (__DEV__) {
typeof Component.contextType === "object" &&
Component.contextType !== null
) {
var _componentName5 =
var _componentName4 =
getComponentNameFromType(Component) || "Unknown";

if (!didWarnAboutContextTypeOnFunctionComponent[_componentName5]) {
if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
error(
"%s: Function components do not support contextType.",
_componentName5
_componentName4
);

didWarnAboutContextTypeOnFunctionComponent[_componentName5] = true;
didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
}
}
}
Expand Down Expand Up @@ -36351,7 +36348,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-31c745b2";
var ReactVersion = "19.0.0-www-classic-ad0567f0";

function createPortal$1(
children,
Expand Down
Loading

0 comments on commit 9f9e660

Please sign in to comment.