@@ -46,7 +46,12 @@ describe('ReactHooks', () => {
46
46
expect ( ( ) => {
47
47
ReactTestRenderer . create ( < Example /> ) ;
48
48
} ) . toThrow (
49
- 'Hooks can only be called inside the body of a function component.' ,
49
+ 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen' +
50
+ ' for one of the following reasons:\n' +
51
+ '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
52
+ '2. You might be breaking the Rules of Hooks\n' +
53
+ '3. You might have more than one copy of React in the same app\n' +
54
+ 'See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.' ,
50
55
) ;
51
56
} ) ;
52
57
}
@@ -875,15 +880,30 @@ describe('ReactHooks', () => {
875
880
const root = ReactTestRenderer . create ( < MemoApp /> ) ;
876
881
// trying to render again should trigger comparison and throw
877
882
expect ( ( ) => root . update ( < MemoApp /> ) ) . toThrow (
878
- 'Hooks can only be called inside the body of a function component' ,
883
+ 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +
884
+ ' one of the following reasons:\n' +
885
+ '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
886
+ '2. You might be breaking the Rules of Hooks\n' +
887
+ '3. You might have more than one copy of React in the same app\n' +
888
+ 'See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.' ,
879
889
) ;
880
890
// the next round, it does a fresh mount, so should render
881
891
expect ( ( ) => root . update ( < MemoApp /> ) ) . not . toThrow (
882
- 'Hooks can only be called inside the body of a function component' ,
892
+ 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +
893
+ ' one of the following reasons:\n' +
894
+ '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
895
+ '2. You might be breaking the Rules of Hooks\n' +
896
+ '3. You might have more than one copy of React in the same app\n' +
897
+ 'See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.' ,
883
898
) ;
884
899
// and then again, fail
885
900
expect ( ( ) => root . update ( < MemoApp /> ) ) . toThrow (
886
- 'Hooks can only be called inside the body of a function component' ,
901
+ 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +
902
+ ' one of the following reasons:\n' +
903
+ '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
904
+ '2. You might be breaking the Rules of Hooks\n' +
905
+ '3. You might have more than one copy of React in the same app\n' +
906
+ 'See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.' ,
887
907
) ;
888
908
} ) ;
889
909
0 commit comments