@freakycoder/react-use-state-with-callback
Version:
Make the useState hook with a callback for React and React Native
6 lines (5 loc) • 339 B
TypeScript
import { SetStateAction } from "react";
declare type Callback<T> = (value?: any) => void;
declare type DispatchWithCallback<T> = (value: any, callback?: Callback<any>) => void;
declare function useStateWithCallback<T>(initialState: any | (() => any)): [any, DispatchWithCallback<SetStateAction<any>>];
export default useStateWithCallback;