rooks
Version:
Essential React custom hooks ⚓ to super charge your components!
32 lines • 1.05 kB
TypeScript
import type { Dispatch, Reducer } from "react";
/**
* Use toggle hook helps you easily toggle a value
*
* @example
* const [value, toggle] = useToggle(false); // initialValue defaults to false
* // value === false
* toggle();
* // value === true
*/
export declare function useToggle<S = boolean>(): [S, () => void];
/**
* Use toggle hook helps you easily toggle a value
*
* @param initialValue the initial value of the boolean
* @example
* const [value, toggle] = useToggle(true);
* // value === true
* toggle();
* // value === false
*/
export declare function useToggle<S>(initialValue: S): [S, Dispatch<unknown>];
/**
* Use toggle hook helps you easily toggle a value
*
* @param initialValue the initial value of the boolean
* @param toggleFunction A toggle function. This allows for non boolean toggles
* @example
* const [value, dispatch] = useToggle(1, myReducer);
*/
export declare function useToggle<S>(initialValue: S, toggleFunction?: Reducer<S, unknown>): [S, Dispatch<unknown>];
//# sourceMappingURL=useToggle.d.ts.map