Skip to content

Commit 58abd5e

Browse files
jaredpalmergaearon
authored andcommitted
Add more info to invalid hook call error message (#15139)
* Add more info to invalid hook call error message * Update other renderers + change call to action * Update related tests for new hooks error message * Fix lint errors
1 parent 781200e commit 58abd5e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ReactShallowRenderer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ class ReactShallowRenderer {
218218
_validateCurrentlyRenderingComponent() {
219219
invariant(
220220
this._rendering && !this._instance,
221-
'Hooks can only be called inside the body of a function component. ' +
222-
'(https://fb.me/react-invalid-hook-call)',
221+
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +
222+
' one of the following reasons:\n' +
223+
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
224+
'2. You might be breaking the Rules of Hooks\n' +
225+
'3. You might have more than one copy of React in the same app\n' +
226+
'See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.',
223227
);
224228
}
225229

0 commit comments

Comments
 (0)