Skip to content

Commit

Permalink
"functional component" -> "function component" in hooks error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored and acdlite committed Oct 29, 2018
1 parent 9e9e397 commit b772e0e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Expand Up @@ -145,7 +145,7 @@ describe('ReactDOMServerHooks', () => {

return render(<Counter />);
},
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);

itRenders('multiple times when an updater is called', async render => {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-dom/src/server/ReactPartialRendererHooks.js
Expand Up @@ -50,7 +50,7 @@ const RE_RENDER_LIMIT = 25;
function resolveCurrentlyRenderingComponent(): Object {
invariant(
currentlyRenderingComponent !== null,
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);
return currentlyRenderingComponent;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ export function finishHooks(
children: any,
refOrContext: any,
): any {
// This must be called after every functional component to prevent hooks from
// This must be called after every function component to prevent hooks from
// being used in classes.

while (didScheduleRenderPhaseUpdate) {
Expand Down Expand Up @@ -321,7 +321,7 @@ function dispatchAction<S, A>(
lastRenderPhaseUpdate.next = update;
}
} else {
// This means an update has happened after the functional component has
// This means an update has happened after the function component has
// returned. On the server this is a no-op. In React Fiber, the update
// would be scheduled for a future render.
}
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberHooks.js
Expand Up @@ -121,7 +121,7 @@ const RE_RENDER_LIMIT = 25;
function resolveCurrentlyRenderingFiber(): Fiber {
invariant(
currentlyRenderingFiber !== null,
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);
return currentlyRenderingFiber;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ export function finishHooks(
children: any,
refOrContext: any,
): any {
// This must be called after every functional component to prevent hooks from
// This must be called after every function component to prevent hooks from
// being used in classes.

while (didScheduleRenderPhaseUpdate) {
Expand Down Expand Up @@ -325,7 +325,7 @@ export function useContext<T>(
context: ReactContext<T>,
observedBits: void | number | boolean,
): T {
// Ensure we're in a functional component (class components support only the
// Ensure we're in a function component (class components support only the
// .unstable_read() form)
resolveCurrentlyRenderingFiber();
return readContext(context, observedBits);
Expand Down
Expand Up @@ -121,7 +121,7 @@ describe('ReactHooks', () => {
ReactNoop.render(<BadCounter />);

expect(() => ReactNoop.flush()).toThrow(
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);

// Confirm that a subsequent hook works properly.
Expand All @@ -144,7 +144,7 @@ describe('ReactHooks', () => {
}
ReactNoop.render(<Counter />);
expect(() => ReactNoop.flush()).toThrow(
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);

// Confirm that a subsequent hook works properly.
Expand All @@ -158,7 +158,7 @@ describe('ReactHooks', () => {

it('throws when called outside the render phase', () => {
expect(() => useState(0)).toThrow(
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);
});

Expand Down
Expand Up @@ -48,7 +48,7 @@ describe('ReactNewContext', () => {
// a suite of tests for a given context consumer implementation.
sharedContextTests('Context.Consumer', Context => Context.Consumer);
sharedContextTests(
'useContext inside functional component',
'useContext inside function component',
Context =>
function Consumer(props) {
const observedBits = props.unstable_observedBits;
Expand Down Expand Up @@ -1342,7 +1342,7 @@ describe('ReactNewContext', () => {
}
ReactNoop.render(<Foo />);
expect(ReactNoop.flush).toThrow(
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ReactHooks.js
Expand Up @@ -16,7 +16,7 @@ function resolveDispatcher() {
const dispatcher = ReactCurrentOwner.currentDispatcher;
invariant(
dispatcher !== null,
'Hooks can only be called inside the body of a functional component.',
'Hooks can only be called inside the body of a function component.',
);
return dispatcher;
}
Expand Down

0 comments on commit b772e0e

Please sign in to comment.