UNPKG

react-custom-hooks-utils

Version:

This library contains a collection of reusable React custom hooks to simplify state management, side effects, and user interactions.

13 lines (9 loc) 247 B
import { useState } from 'react'; function useToggle(initialValue = false) { const [value, setValue] = useState(initialValue); const toggle = () => { setValue((prev) => !prev); }; return [value, toggle]; } export default useToggle;