diff --git a/src/index.ts b/src/index.ts index 039e866..74d3eb5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,11 +67,13 @@ function setRef(this: Store, newState: T): void { export type HookWork = () => T; +export type UseCustomHook = [T, A] | [T, A, ...WorkR[]]; + function useCustom( this: Store, React: ReactLib, hookWork?: HookWork -): [T, A, ...WorkR[]] { +): UseCustomHook { const newListener = React.useState()[1]; React.useEffect(() => { this.listeners.push(newListener); @@ -130,7 +132,7 @@ const useStore = < actions = baseActions, initializer, }: UseStoreProps = {} as UseStoreProps -): ((_?: HookWork) => [T, OuterA, ...WorkR[]]) => { +): ((_?: HookWork) => UseCustomHook) => { const store = { state: initialState, listeners: [] } as Store; store.setState = setState.bind(store); store.setRef = setRef.bind(store);