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 commit a73c345.
  • Loading branch information
kassens committed Mar 29, 2024
1 parent 7e5c5c5 commit d777384
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b3f8b9d9ae41ad4e84b986ff88b107f6>>
* @generated SignedSource<<2123de3808a6ddc6df79e3bd382b5c8a>>
*/

"use strict";
Expand Down Expand Up @@ -14729,20 +14729,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 @@ -14781,33 +14778,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 @@ -14816,16 +14813,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 @@ -26252,7 +26249,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-canary-6c021864";
var ReactVersion = "19.0.0-canary-5cab92f5";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a6a6d1e6f1aaf9b35c7e831132de38c7>>
* @generated SignedSource<<2f7fdc919cfa317eb2f8911daed24f70>>
*/

"use strict";
Expand Down Expand Up @@ -4925,8 +4925,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 @@ -9186,7 +9185,7 @@ var devToolsConfig$jscomp$inline_1009 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-34d57ea6",
version: "19.0.0-canary-c6c9bbb9",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1197 = {
Expand Down Expand Up @@ -9217,7 +9216,7 @@ var internals$jscomp$inline_1197 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-34d57ea6"
reconcilerVersion: "19.0.0-canary-c6c9bbb9"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1198 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a770edfebf8c3b9defa939442fec4e9f>>
* @generated SignedSource<<d6ee8310e3b8ca455c7eec67ecf555a2>>
*/

"use strict";
Expand Down Expand Up @@ -5027,8 +5027,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 @@ -9612,7 +9611,7 @@ var devToolsConfig$jscomp$inline_1052 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-canary-a4b56d0a",
version: "19.0.0-canary-3d347368",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1238 = {
Expand Down Expand Up @@ -9643,7 +9642,7 @@ var internals$jscomp$inline_1238 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-a4b56d0a"
reconcilerVersion: "19.0.0-canary-3d347368"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1239 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f2690747239533fa266612d2d4dd9ae88ea92fbc
a73c3450e1b528fa6cb3e94fa4d4359c7a4b61f1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b96b1db3ec870619c9c09b3905a87f32>>
* @generated SignedSource<<359ce6fb063e371084bf38d1957253bd>>
*/

"use strict";
Expand Down Expand Up @@ -18790,20 +18790,17 @@ to return true:wantsResponderID| |
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 @@ -18842,33 +18839,33 @@ to return true:wantsResponderID| |
}

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 @@ -18877,16 +18874,16 @@ to return true:wantsResponderID| |
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 @@ -30583,7 +30580,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "19.0.0-canary-fb494e93";
var ReactVersion = "19.0.0-canary-7938b6a8";

function createPortal$1(
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<290dfece63aea68ecb6f52375631b2ff>>
* @generated SignedSource<<6caf0298fd44810887edd334677ec6ef>>
*/

"use strict";
Expand Down Expand Up @@ -6507,8 +6507,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 @@ -10639,7 +10638,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1104 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-canary-c845e507",
version: "19.0.0-canary-3aaf7c49",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10682,7 +10681,7 @@ var internals$jscomp$inline_1341 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-c845e507"
reconcilerVersion: "19.0.0-canary-3aaf7c49"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1342 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<48687683c293fb45d02204564978a6b7>>
* @generated SignedSource<<7eba5ed56d62fd3b39e8d3ac4bd0561c>>
*/

"use strict";
Expand Down Expand Up @@ -6733,8 +6733,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 @@ -11346,7 +11345,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1186 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-canary-b92bb150",
version: "19.0.0-canary-270b90fe",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11402,7 +11401,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-canary-b92bb150"
reconcilerVersion: "19.0.0-canary-270b90fe"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Loading

0 comments on commit d777384

Please sign in to comment.