// Type definitions for react-hookz 1.0 // Project: https://github.com/garywenneker/react-hookz#readme // Definitions by: Gary Wenneker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.6 // Use an interface so that different versions of React can be used interface ReactInterface { useEffect: (...args: any[]) => any; useState: (...args: any[]) => any; useMemo: (...args: any[]) => any; } // to ignore strict-export-declare-modifiers error export {}; // Where S is typeof state and A is typeof associated actions export interface Store { state: S; actions: A; setState(state: S, afterUpdateCallback?: () => void): void; } export type InitializerFunction = (store: Store) => void; type UseGlobal = (() => [S, A]) & ((stateFunc: (state: S) => NS) => [NS, A]) & ((stateFunc: (state: S) => NS, actionsFunc: (state: A) => NA) => [NS, NA]) & ((stateFunc: undefined, actionsFunc: (state: A) => NA) => [S, NA]); export function useStore( React: ReactInterface, inititalState: S, actions: object, initializers?: InitializerFunction, ): UseGlobal;