@@ -1028,40 +1028,67 @@ describe('context legacy', () => {
1028
1028
root . render ( < Root /> ) ;
1029
1029
} ) ;
1030
1030
1031
- assertConsoleErrorDev ( [
1032
- 'LegacyContextProvider uses the legacy childContextTypes API ' +
1033
- 'which will soon be removed. Use React.createContext() instead. ' +
1034
- '(https://react.dev/link/legacy-context)' +
1035
- '\n in LegacyContextProvider (at **)' +
1036
- '\n in div (at **)' +
1037
- '\n in Root (at **)' ,
1038
- 'LegacyContextConsumer uses the legacy contextTypes API which ' +
1039
- 'will soon be removed. Use React.createContext() with static ' +
1040
- 'contextType instead. (https://react.dev/link/legacy-context)' +
1041
- '\n in LegacyContextConsumer (at **)' +
1042
- '\n in div (at **)' +
1043
- '\n in LegacyContextProvider (at **)' +
1044
- '\n in div (at **)' +
1045
- '\n in Root (at **)' ,
1046
- 'FunctionalLegacyContextConsumer uses the legacy contextTypes ' +
1047
- 'API which will be removed soon. Use React.createContext() ' +
1048
- 'with React.useContext() instead. (https://react.dev/link/legacy-context)' +
1049
- '\n in FunctionalLegacyContextConsumer (at **)' +
1050
- '\n in div (at **)' +
1051
- '\n in LegacyContextProvider (at **)' +
1052
- '\n in div (at **)' +
1053
- '\n in Root (at **)' ,
1054
- 'Legacy context API has been detected within a strict-mode tree.' +
1055
- '\n\nThe old API will be supported in all 16.x releases, but applications ' +
1056
- 'using it should migrate to the new version.' +
1057
- '\n\nPlease update the following components: ' +
1058
- 'FunctionalLegacyContextConsumer, LegacyContextConsumer, LegacyContextProvider' +
1059
- '\n\nLearn more about this warning here: ' +
1060
- 'https://react.dev/link/legacy-context' +
1061
- '\n in LegacyContextProvider (at **)' +
1062
- '\n in div (at **)' +
1063
- '\n in Root (at **)' ,
1064
- ] ) ;
1031
+ if ( gate ( flags => flags . enableOwnerStacks ) ) {
1032
+ assertConsoleErrorDev ( [
1033
+ 'LegacyContextProvider uses the legacy childContextTypes API ' +
1034
+ 'which will soon be removed. Use React.createContext() instead. ' +
1035
+ '(https://react.dev/link/legacy-context)' +
1036
+ '\n in Root (at **)' ,
1037
+ 'LegacyContextConsumer uses the legacy contextTypes API which ' +
1038
+ 'will soon be removed. Use React.createContext() with static ' +
1039
+ 'contextType instead. (https://react.dev/link/legacy-context)' +
1040
+ '\n in LegacyContextProvider (at **)' +
1041
+ '\n in Root (at **)' ,
1042
+ 'FunctionalLegacyContextConsumer uses the legacy contextTypes ' +
1043
+ 'API which will be removed soon. Use React.createContext() ' +
1044
+ 'with React.useContext() instead. (https://react.dev/link/legacy-context)' +
1045
+ '\n in LegacyContextProvider (at **)' +
1046
+ '\n in Root (at **)' ,
1047
+ 'Legacy context API has been detected within a strict-mode tree.' +
1048
+ '\n\nThe old API will be supported in all 16.x releases, but applications ' +
1049
+ 'using it should migrate to the new version.' +
1050
+ '\n\nPlease update the following components: ' +
1051
+ 'FunctionalLegacyContextConsumer, LegacyContextConsumer, LegacyContextProvider' +
1052
+ '\n\nLearn more about this warning here: ' +
1053
+ 'https://react.dev/link/legacy-context' +
1054
+ '\n in Root (at **)' ,
1055
+ ] ) ;
1056
+ } else {
1057
+ assertConsoleErrorDev ( [
1058
+ 'LegacyContextProvider uses the legacy childContextTypes API ' +
1059
+ 'which will soon be removed. Use React.createContext() instead. ' +
1060
+ '(https://react.dev/link/legacy-context)' +
1061
+ '\n in LegacyContextProvider (at **)' +
1062
+ '\n in div (at **)' +
1063
+ '\n in Root (at **)' ,
1064
+ 'LegacyContextConsumer uses the legacy contextTypes API which ' +
1065
+ 'will soon be removed. Use React.createContext() with static ' +
1066
+ 'contextType instead. (https://react.dev/link/legacy-context)' +
1067
+ '\n in LegacyContextConsumer (at **)' +
1068
+ '\n in div (at **)' +
1069
+ '\n in LegacyContextProvider (at **)' +
1070
+ '\n in div (at **)' +
1071
+ '\n in Root (at **)' ,
1072
+ 'FunctionalLegacyContextConsumer uses the legacy contextTypes ' +
1073
+ 'API which will be removed soon. Use React.createContext() ' +
1074
+ 'with React.useContext() instead. (https://react.dev/link/legacy-context)' +
1075
+ '\n in FunctionalLegacyContextConsumer (at **)' +
1076
+ '\n in div (at **)' +
1077
+ '\n in LegacyContextProvider (at **)' +
1078
+ '\n in div (at **)' +
1079
+ '\n in Root (at **)' ,
1080
+ 'Legacy context API has been detected within a strict-mode tree.' +
1081
+ '\n\nThe old API will be supported in all 16.x releases, but applications ' +
1082
+ 'using it should migrate to the new version.' +
1083
+ '\n\nPlease update the following components: ' +
1084
+ 'FunctionalLegacyContextConsumer, LegacyContextConsumer, LegacyContextProvider' +
1085
+ '\n\nLearn more about this warning here: ' +
1086
+ 'https://react.dev/link/legacy-context' +
1087
+ '\n in LegacyContextProvider (at **)' +
1088
+ '\n in div (at **)' +
1089
+ '\n in Root (at **)' ,
1090
+ ] ) ;
1091
+ }
1065
1092
1066
1093
// Dedupe
1067
1094
await act ( ( ) => {
0 commit comments