@samitouri / QOS-React / commits / 5045763064

Swap order of function member in hook union types

Andrew Clark committed Oct 29, 2018 at 11:39 UTC 504576306461a5ff339dc99691842f0f35a8bf4c
3 files changed +5 -5
packages/react-dom/src/server/ReactPartialRendererHooks.js
+2 -2
@@ -11,7 +11,7 @@ import type {ReactContext} from 'shared/ReactTypes';
11 import invariant from 'shared/invariant';
12 import warning from 'shared/warning';
13
14 -type BasicStateAction<S> = S | (S => S);
14 +type BasicStateAction<S> = (S => S) | S;
15 type MaybeCallback<S> = void | null | (S => mixed);
16 type Dispatch<S, A> = (A, MaybeCallback<S>) => void;
17
@@ -158,7 +158,7 @@ function basicStateReducer<S>(state: S, action: BasicStateAction<S>): S {
158 }
159
160 export function useState<S>(
161 - initialState: S | (() => S),
161 + initialState: (() => S) | S,
162 ): [S, Dispatch<S, BasicStateAction<S>>] {
163 return useReducer(
164 basicStateReducer,
packages/react-reconciler/src/ReactFiberHooks.js
+2 -2
@@ -75,7 +75,7 @@ export type FunctionComponentUpdateQueue = {
75 lastEffect: Effect | null,
76 };
77
78 -type BasicStateAction<S> = S | (S => S);
78 +type BasicStateAction<S> = (S => S) | S;
79
80 type MaybeCallback<S> = void | null | (S => mixed);
81
@@ -332,7 +332,7 @@ export function useContext<T>(
332 }
333
334 export function useState<S>(
335 - initialState: S | (() => S),
335 + initialState: (() => S) | S,
336 ): [S, Dispatch<S, BasicStateAction<S>>] {
337 return useReducer(
338 basicStateReducer,
packages/react/src/ReactHooks.js
+1 -1
@@ -51,7 +51,7 @@ export function useContext<T>(
51 return dispatcher.useContext(Context, observedBits);
52 }
53
54 -export function useState<S>(initialState: S | (() => S)) {
54 +export function useState<S>(initialState: (() => S) | S) {
55 const dispatcher = resolveDispatcher();
56 return dispatcher.useState(initialState);
57 }