@@ -3866,13 +3866,12 @@ describe('ReactHooksWithNoopRenderer', () => {
3866
3866
3867
3867
ReactNoop . render ( < App loadA = { true } /> ) ;
3868
3868
expect ( ( ) => {
3869
- const expectFlush = expect ( ( ) => {
3870
- expect ( Scheduler ) . toFlushAndYield ( [ 'A: 0' ] ) ;
3871
- } ) ;
3872
3869
if ( gate ( flag => flag . enableThrowOnMountForHookMismatch ) ) {
3873
- expectFlush . toThrow (
3874
- 'Rendered more hooks than during the previous render' ,
3875
- ) ;
3870
+ expect ( ( ) => {
3871
+ expect ( Scheduler ) . toFlushAndYield ( [ 'A: 0' ] ) ;
3872
+ } ) . toThrow ( 'Rendered more hooks than during the previous render' ) ;
3873
+ } else {
3874
+ expect ( Scheduler ) . toFlushAndYield ( [ 'A: 0' ] ) ;
3876
3875
}
3877
3876
} ) . toErrorDev ( [
3878
3877
'Warning: React has detected a change in the order of Hooks called by App. ' +
@@ -3974,24 +3973,34 @@ describe('ReactHooksWithNoopRenderer', () => {
3974
3973
3975
3974
act ( ( ) => {
3976
3975
ReactNoop . render ( < App showMore = { true } /> ) ;
3977
- expect ( ( ) => {
3978
- const expectFlush = expect ( ( ) => {
3976
+ if ( gate ( flags => flags . enableThrowOnMountForHookMismatch ) ) {
3977
+ expect ( ( ) => {
3978
+ expect ( ( ) => {
3979
+ expect ( Scheduler ) . toFlushAndYield ( [ 'Mount A' ] ) ;
3980
+ } ) . toThrow ( 'Rendered more hooks than during the previous render' ) ;
3981
+ } ) . toErrorDev ( [
3982
+ 'Warning: React has detected a change in the order of Hooks called by App. ' +
3983
+ 'This will lead to bugs and errors if not fixed. For more information, ' +
3984
+ 'read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n' +
3985
+ ' Previous render Next render\n' +
3986
+ ' ------------------------------------------------------\n' +
3987
+ '1. undefined useEffect\n' +
3988
+ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n' ,
3989
+ ] ) ;
3990
+ } else {
3991
+ expect ( ( ) => {
3979
3992
expect ( Scheduler ) . toFlushAndYield ( [ 'Mount A' ] ) ;
3980
- } ) ;
3981
- if ( gate ( flags => flags . enableThrowOnMountForHookMismatch ) ) {
3982
- expectFlush . toThrow (
3983
- 'Rendered more hooks than during the previous render' ,
3984
- ) ;
3985
- }
3986
- } ) . toErrorDev ( [
3987
- 'Warning: React has detected a change in the order of Hooks called by App. ' +
3988
- 'This will lead to bugs and errors if not fixed. For more information, ' +
3989
- 'read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n' +
3990
- ' Previous render Next render\n' +
3991
- ' ------------------------------------------------------\n' +
3992
- '1. undefined useEffect\n' +
3993
- ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n' ,
3994
- ] ) ;
3993
+ } ) . toErrorDev ( [
3994
+ 'Warning: Internal React error: Expected static flag was missing. Please notify the React team.' ,
3995
+ 'Warning: React has detected a change in the order of Hooks called by App. ' +
3996
+ 'This will lead to bugs and errors if not fixed. For more information, ' +
3997
+ 'read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n' +
3998
+ ' Previous render Next render\n' +
3999
+ ' ------------------------------------------------------\n' +
4000
+ '1. undefined useEffect\n' +
4001
+ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n' ,
4002
+ ] ) ;
4003
+ }
3995
4004
} ) ;
3996
4005
} ) ;
3997
4006
0 commit comments