Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks in function components error link #14690

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/react-dom/src/server/ReactPartialRendererHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ let currentHookNameInDev: ?string;
function resolveCurrentlyRenderingComponent(): Object {
invariant(
currentlyRenderingComponent !== null,
'Hooks can only be called inside the body of a function component.',
'Hooks can only be called inside the body of a function component. ' +
'See https://fb.me/react-hooks-in-function-components for more information',
);
return currentlyRenderingComponent;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ let currentHookNameInDev: ?HookType = null;
function resolveCurrentlyRenderingFiber(): Fiber {
invariant(
currentlyRenderingFiber !== null,
'Hooks can only be called inside the body of a function component.',
'Hooks can only be called inside the body of a function component. ' +
'See https://fb.me/react-hooks-in-function-components for more information',
);
return currentlyRenderingFiber;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-test-renderer/src/ReactShallowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ class ReactShallowRenderer {
_validateCurrentlyRenderingComponent() {
invariant(
this._currentlyRenderingComponent !== null,
'Hooks can only be called inside the body of a function component.',
'Hooks can only be called inside the body of a function component.' +
'See https://fb.me/react-hooks-in-function-components for more information',
);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/ReactHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function resolveDispatcher() {
const dispatcher = ReactCurrentDispatcher.current;
invariant(
dispatcher !== null,
'Hooks can only be called inside the body of a function component.',
'Hooks can only be called inside the body of a function component. ' +
'See https://fb.me/react-hooks-in-function-components for more information',
);
return dispatcher;
}
Expand Down