Skip to content

Commit c8b941f

Browse files
committed
Warn about legacy context when legacy context is not disabled (#30297)
For environments that still have legacy contexts available, this adds a warning to make the remaining call sites easier to locate and encourage upgrades. DiffTrain build for [378b305](378b305)
1 parent 6460f04 commit c8b941f

36 files changed

+851
-536
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3b2e5f27c5b72708677da27779852b9aa83ef909
1+
378b305958eb7259cacfce8ad0e66eec07e07074
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3b2e5f27c5b72708677da27779852b9aa83ef909
1+
378b305958eb7259cacfce8ad0e66eec07e07074

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ __DEV__ &&
19981998
exports.useTransition = function () {
19991999
return resolveDispatcher().useTransition();
20002000
};
2001-
exports.version = "19.0.0-www-classic-3b2e5f27c5-20240710";
2001+
exports.version = "19.0.0-www-classic-378b305958-20240710";
20022002
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
20032003
"function" ===
20042004
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ __DEV__ &&
19781978
exports.useTransition = function () {
19791979
return resolveDispatcher().useTransition();
19801980
};
1981-
exports.version = "19.0.0-www-modern-3b2e5f27c5-20240710";
1981+
exports.version = "19.0.0-www-modern-378b305958-20240710";
19821982
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19831983
"function" ===
19841984
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,4 +669,4 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-classic-3b2e5f27c5-20240710";
672+
exports.version = "19.0.0-www-classic-378b305958-20240710";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,4 +669,4 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-modern-3b2e5f27c5-20240710";
672+
exports.version = "19.0.0-www-modern-378b305958-20240710";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ exports.useSyncExternalStore = function (
673673
exports.useTransition = function () {
674674
return ReactSharedInternals.H.useTransition();
675675
};
676-
exports.version = "19.0.0-www-classic-3b2e5f27c5-20240710";
676+
exports.version = "19.0.0-www-classic-378b305958-20240710";
677677
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
678678
"function" ===
679679
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ exports.useSyncExternalStore = function (
673673
exports.useTransition = function () {
674674
return ReactSharedInternals.H.useTransition();
675675
};
676-
exports.version = "19.0.0-www-modern-3b2e5f27c5-20240710";
676+
exports.version = "19.0.0-www-modern-378b305958-20240710";
677677
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
678678
"function" ===
679679
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5796,6 +5796,20 @@ __DEV__ &&
57965796
"%s declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.",
57975797
name
57985798
));
5799+
ctor.childContextTypes &&
5800+
!didWarnAboutChildContextTypes.has(ctor) &&
5801+
(didWarnAboutChildContextTypes.add(ctor),
5802+
error$jscomp$0(
5803+
"%s uses the legacy childContextTypes API which will soon be removed. Use React.createContext() instead. (https://react.dev/link/legacy-context)",
5804+
name
5805+
));
5806+
ctor.contextTypes &&
5807+
!didWarnAboutContextTypes$1.has(ctor) &&
5808+
(didWarnAboutContextTypes$1.add(ctor),
5809+
error$jscomp$0(
5810+
"%s uses the legacy contextTypes API which will soon be removed. Use React.createContext() with static contextType instead. (https://react.dev/link/legacy-context)",
5811+
name
5812+
));
57995813
"function" === typeof instance.componentShouldUpdate &&
58005814
error$jscomp$0(
58015815
"%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",
@@ -6697,7 +6711,15 @@ __DEV__ &&
66976711
null
66986712
);
66996713
null === current &&
6700-
validateFunctionComponentInDev(workInProgress, workInProgress.type);
6714+
(validateFunctionComponentInDev(workInProgress, workInProgress.type),
6715+
Component.contextTypes &&
6716+
((componentName = getComponentNameFromType(Component) || "Unknown"),
6717+
didWarnAboutContextTypes[componentName] ||
6718+
((didWarnAboutContextTypes[componentName] = !0),
6719+
error$jscomp$0(
6720+
"%s uses the legacy contextTypes API which will be removed soon. Use React.createContext() with React.useContext() instead. (https://react.dev/link/legacy-context)",
6721+
componentName
6722+
))));
67016723
componentName = isContextProvider(Component)
67026724
? previousContext
67036725
: contextStackCursor$1.current;
@@ -16416,6 +16438,8 @@ __DEV__ &&
1641616438
var didWarnAboutDirectlyAssigningPropsToState = new Set();
1641716439
var didWarnAboutUndefinedDerivedState = new Set();
1641816440
var didWarnAboutContextTypeAndContextTypes = new Set();
16441+
var didWarnAboutContextTypes$1 = new Set();
16442+
var didWarnAboutChildContextTypes = new Set();
1641916443
var didWarnAboutInvalidateContextType = new Set();
1642016444
var didWarnOnInvalidCallback = new Set();
1642116445
Object.freeze(fakeInternalInstance);
@@ -16543,6 +16567,7 @@ __DEV__ &&
1654316567
didReceiveUpdate = !1;
1654416568
var didWarnAboutBadClass = {};
1654516569
var didWarnAboutContextTypeOnFunctionComponent = {};
16570+
var didWarnAboutContextTypes = {};
1654616571
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
1654716572
var didWarnAboutReassigningProps = !1;
1654816573
var didWarnAboutRevealOrder = {};
@@ -16937,14 +16962,14 @@ __DEV__ &&
1693716962
scheduleRoot: scheduleRoot,
1693816963
setRefreshHandler: setRefreshHandler,
1693916964
getCurrentFiber: getCurrentFiberForDevTools,
16940-
reconcilerVersion: "19.0.0-www-classic-3b2e5f27c5-20240710"
16965+
reconcilerVersion: "19.0.0-www-classic-378b305958-20240710"
1694116966
});
1694216967
})({
1694316968
findFiberByHostInstance: function () {
1694416969
return null;
1694516970
},
1694616971
bundleType: 1,
16947-
version: "19.0.0-www-classic-3b2e5f27c5-20240710",
16972+
version: "19.0.0-www-classic-378b305958-20240710",
1694816973
rendererPackageName: "react-art"
1694916974
});
1695016975
var ClippingRectangle = TYPES.CLIPPING_RECTANGLE,

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6243,10 +6243,13 @@ __DEV__ &&
62436243
null === current &&
62446244
(validateFunctionComponentInDev(workInProgress, workInProgress.type),
62456245
Component.contextTypes &&
6246-
error$jscomp$0(
6247-
"%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with React.useContext() instead.",
6248-
getComponentNameFromType(Component) || "Unknown"
6249-
));
6246+
((componentName = getComponentNameFromType(Component) || "Unknown"),
6247+
didWarnAboutContextTypes[componentName] ||
6248+
((didWarnAboutContextTypes[componentName] = !0),
6249+
error$jscomp$0(
6250+
"%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with React.useContext() instead. (https://react.dev/link/legacy-context)",
6251+
componentName
6252+
))));
62506253
prepareToReadContext(workInProgress, renderLanes);
62516254
enableSchedulingProfiler && markComponentRenderStarted(workInProgress);
62526255
Component = renderWithHooks(
@@ -6463,14 +6466,14 @@ __DEV__ &&
64636466
!didWarnAboutChildContextTypes.has(Component) &&
64646467
(didWarnAboutChildContextTypes.add(Component),
64656468
error$jscomp$0(
6466-
"%s uses the legacy childContextTypes API which was removed in React 19. Use React.createContext() instead.",
6469+
"%s uses the legacy childContextTypes API which was removed in React 19. Use React.createContext() instead. (https://react.dev/link/legacy-context)",
64676470
state
64686471
));
64696472
Component.contextTypes &&
6470-
!didWarnAboutContextTypes.has(Component) &&
6471-
(didWarnAboutContextTypes.add(Component),
6473+
!didWarnAboutContextTypes$1.has(Component) &&
6474+
(didWarnAboutContextTypes$1.add(Component),
64726475
error$jscomp$0(
6473-
"%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with static contextType instead.",
6476+
"%s uses the legacy contextTypes API which was removed in React 19. Use React.createContext() with static contextType instead. (https://react.dev/link/legacy-context)",
64746477
state
64756478
));
64766479
"function" === typeof _instance.componentShouldUpdate &&
@@ -15851,7 +15854,7 @@ __DEV__ &&
1585115854
var didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
1585215855
var didWarnAboutDirectlyAssigningPropsToState = new Set();
1585315856
var didWarnAboutUndefinedDerivedState = new Set();
15854-
var didWarnAboutContextTypes = new Set();
15857+
var didWarnAboutContextTypes$1 = new Set();
1585515858
var didWarnAboutChildContextTypes = new Set();
1585615859
var didWarnAboutInvalidateContextType = new Set();
1585715860
var didWarnOnInvalidCallback = new Set();
@@ -15980,6 +15983,7 @@ __DEV__ &&
1598015983
didReceiveUpdate = !1;
1598115984
var didWarnAboutBadClass = {};
1598215985
var didWarnAboutContextTypeOnFunctionComponent = {};
15986+
var didWarnAboutContextTypes = {};
1598315987
var didWarnAboutGetDerivedStateOnFunctionComponent = {};
1598415988
var didWarnAboutReassigningProps = !1;
1598515989
var didWarnAboutRevealOrder = {};
@@ -16373,14 +16377,14 @@ __DEV__ &&
1637316377
scheduleRoot: scheduleRoot,
1637416378
setRefreshHandler: setRefreshHandler,
1637516379
getCurrentFiber: getCurrentFiberForDevTools,
16376-
reconcilerVersion: "19.0.0-www-modern-3b2e5f27c5-20240710"
16380+
reconcilerVersion: "19.0.0-www-modern-378b305958-20240710"
1637716381
});
1637816382
})({
1637916383
findFiberByHostInstance: function () {
1638016384
return null;
1638116385
},
1638216386
bundleType: 1,
16383-
version: "19.0.0-www-modern-3b2e5f27c5-20240710",
16387+
version: "19.0.0-www-modern-378b305958-20240710",
1638416388
rendererPackageName: "react-art"
1638516389
});
1638616390
var ClippingRectangle = TYPES.CLIPPING_RECTANGLE,

0 commit comments

Comments
 (0)