UNPKG

react-hook-granth

Version:

A collection of custom React hooks for efficient state management and UI logic.

14 lines (9 loc) 383 B
import { useState } from "react"; const useCounter = (initialValue = 0) => { const [count, setCount] = useState(initialValue); const increment = () => setCount((prev) => prev + 1); const decrement = () => setCount((prev) => prev - 1); const reset = () => setCount(initialValue); return { count, increment, decrement, reset }; }; export default useCounter;