@@ -880,7 +880,6 @@ describe('ReactErrorBoundaries', () => {
880
880
} ) ;
881
881
882
882
// @gate !disableModulePatternComponents
883
- // @gate !disableLegacyContext
884
883
it ( 'renders an error state if module-style context provider throws in componentWillMount' , async ( ) => {
885
884
function BrokenComponentWillMountWithContext ( ) {
886
885
return {
@@ -901,23 +900,31 @@ describe('ReactErrorBoundaries', () => {
901
900
902
901
const container = document . createElement ( 'div' ) ;
903
902
const root = ReactDOMClient . createRoot ( container ) ;
904
- await expect (
905
- async ( ) =>
906
- await act ( async ( ) => {
907
- root . render (
908
- < ErrorBoundary >
909
- < BrokenComponentWillMountWithContext />
910
- </ ErrorBoundary > ,
911
- ) ;
912
- } ) ,
913
- ) . toErrorDev (
903
+
904
+ await expect ( async ( ) => {
905
+ await act ( ( ) => {
906
+ root . render (
907
+ < ErrorBoundary >
908
+ < BrokenComponentWillMountWithContext />
909
+ </ ErrorBoundary > ,
910
+ ) ;
911
+ } ) ;
912
+ } ) . toErrorDev ( [
914
913
'Warning: The <BrokenComponentWillMountWithContext /> component appears to be a function component that ' +
915
914
'returns a class instance. ' +
916
915
'Change BrokenComponentWillMountWithContext to a class that extends React.Component instead. ' +
917
916
"If you can't use a class try assigning the prototype on the function as a workaround. " +
918
917
'`BrokenComponentWillMountWithContext.prototype = React.Component.prototype`. ' +
919
918
"Don't use an arrow function since it cannot be called with `new` by React." ,
920
- ) ;
919
+ ...gate ( flags =>
920
+ flags . disableLegacyContext
921
+ ? [
922
+ 'Warning: BrokenComponentWillMountWithContext uses the legacy childContextTypes API which is no longer supported. Use React.createContext() instead.' ,
923
+ 'Warning: BrokenComponentWillMountWithContext uses the legacy childContextTypes API which is no longer supported. Use React.createContext() instead.' ,
924
+ ]
925
+ : [ ] ,
926
+ ) ,
927
+ ] ) ;
921
928
922
929
expect ( container . firstChild . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
923
930
} ) ;
0 commit comments