import { Dispatcher } from '../react-reconciler/ReactInternalTypes' ; import { ReactCurrentDispatcher } from './ReactCurrentDispatcher' ; type BasicStateAction < S > = ( ( a : S ) => S ) | S ; type Dispatch < A > = ( a : A ) => void ; returns const resolveDispatcher = ( ) : Dispatcher => { const dispatcher = ReactCurrentDispatcher . current ; return dispatcher ! ; } ; param initialState returns export const useState = < S > ( initialState ) : [ S , Dispatch < BasicStateAction < S > > ] => { const dispatcher = resolveDispatcher ( ) ; return dispatcher . useState ( initialState ) ; } ; export const useEffect = ( create , deps ) : void => { const dispatcher = resolveDispatcher ( ) ; return dispatcher . useEffect ( create , deps ) ; } ; export const useLayoutEffect = ( create , deps ) : void => { const dispatcher = resolveDispatcher ( ) ; return dispatcher . useLayoutEffect ( create , deps ) ; } ;