Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
"functional component" -> "function component" in hooks error messages
  • Loading branch information
sebmarkbage authored and acdlite committed Oct 29, 2018
commit b772e0e26bd8f3062e23e9d831045a39072d0372
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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