Skip to content

Commit

Permalink
Swap order of function member in hook union types
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Oct 29, 2018
1 parent ddbfe2e commit 5045763
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactPartialRendererHooks.js
Expand Up @@ -11,7 +11,7 @@ import type {ReactContext} from 'shared/ReactTypes';
import invariant from 'shared/invariant';
import warning from 'shared/warning';

type BasicStateAction<S> = S | (S => S);
type BasicStateAction<S> = (S => S) | S;
type MaybeCallback<S> = void | null | (S => mixed);
type Dispatch<S, A> = (A, MaybeCallback<S>) => void;

Expand Down Expand Up @@ -158,7 +158,7 @@ function basicStateReducer<S>(state: S, action: BasicStateAction<S>): S {
}

export function useState<S>(
initialState: S | (() => S),
initialState: (() => S) | S,
): [S, Dispatch<S, BasicStateAction<S>>] {
return useReducer(
basicStateReducer,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.js
Expand Up @@ -75,7 +75,7 @@ export type FunctionComponentUpdateQueue = {
lastEffect: Effect | null,
};

type BasicStateAction<S> = S | (S => S);
type BasicStateAction<S> = (S => S) | S;

type MaybeCallback<S> = void | null | (S => mixed);

Expand Down Expand Up @@ -332,7 +332,7 @@ export function useContext<T>(
}

export function useState<S>(
initialState: S | (() => S),
initialState: (() => S) | S,
): [S, Dispatch<S, BasicStateAction<S>>] {
return useReducer(
basicStateReducer,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ReactHooks.js
Expand Up @@ -51,7 +51,7 @@ export function useContext<T>(
return dispatcher.useContext(Context, observedBits);
}

export function useState<S>(initialState: S | (() => S)) {
export function useState<S>(initialState: (() => S) | S) {
const dispatcher = resolveDispatcher();
return dispatcher.useState(initialState);
}
Expand Down

0 comments on commit 5045763

Please sign in to comment.