@@ -665,7 +665,7 @@ describe('ReactHooks', () => {
665
665
return null ;
666
666
}
667
667
expect ( ( ) => ReactTestRenderer . create ( < App /> ) ) . toWarnDev (
668
- 'Hooks can only be called inside the body of a function component ' ,
668
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' ,
669
669
) ;
670
670
} ) ;
671
671
@@ -835,12 +835,12 @@ describe('ReactHooks', () => {
835
835
if ( __DEV__ ) {
836
836
expect ( console . error ) . toHaveBeenCalledTimes ( 3 ) ;
837
837
expect ( console . error . calls . argsFor ( 0 ) [ 0 ] ) . toContain (
838
- 'Hooks can only be called inside the body of a function component ' ,
838
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks ' ,
839
839
) ;
840
840
}
841
841
} ) ;
842
842
843
- it ( "throws when calling hooks inside useState's initialize function" , ( ) => {
843
+ it ( "warns when calling hooks inside useState's initialize function" , ( ) => {
844
844
const { useState, useRef} = React ;
845
845
function App ( ) {
846
846
useState ( ( ) => {
@@ -850,7 +850,7 @@ describe('ReactHooks', () => {
850
850
return null ;
851
851
}
852
852
expect ( ( ) => ReactTestRenderer . create ( < App /> ) ) . toWarnDev (
853
- 'Hooks can only be called inside the body of a function component ' ,
853
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' ,
854
854
) ;
855
855
} ) ;
856
856
@@ -892,9 +892,9 @@ describe('ReactHooks', () => {
892
892
} ) . toWarnDev ( [
893
893
// We see it twice due to replay
894
894
'Context can only be read while React is rendering' ,
895
- 'Hooks can only be called inside the body of a function component ' ,
895
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks ' ,
896
896
'Context can only be read while React is rendering' ,
897
- 'Hooks can only be called inside the body of a function component ' ,
897
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks ' ,
898
898
] ) ;
899
899
900
900
function Valid ( ) {
@@ -925,9 +925,9 @@ describe('ReactHooks', () => {
925
925
} ) . toWarnDev ( [
926
926
// We see it twice due to replay
927
927
'Context can only be read while React is rendering' ,
928
- 'Hooks can only be called inside the body of a function component ' ,
928
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks ' ,
929
929
'Context can only be read while React is rendering' ,
930
- 'Hooks can only be called inside the body of a function component ' ,
930
+ 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks ' ,
931
931
] ) ;
932
932
} ) ;
933
933
0 commit comments