Skip to content

Commit

Permalink
Add more info to invalid hook call error message (#15139)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jaredpalmer authored and gaearon committed Mar 18, 2019
1 parent 781200e commit 58abd5e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ReactShallowRenderer.js
Expand Up @@ -218,8 +218,12 @@ class ReactShallowRenderer {
_validateCurrentlyRenderingComponent() {
invariant(
this._rendering && !this._instance,
'Hooks can only be called inside the body of a function component. ' +
'(https://fb.me/react-invalid-hook-call)',
'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' +
' one of the following reasons:\n' +
'1. You might have mismatching versions of React and the renderer (such as React DOM)\n' +
'2. You might be breaking the Rules of Hooks\n' +
'3. You might have more than one copy of React in the same app\n' +
'See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.',
);
}

Expand Down

0 comments on commit 58abd5e

Please sign in to comment.