Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/deps/usehooks-ts.ts>useCounter

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useCounter
import { useCounter } from "https://deno.land/x/netzo@0.5.63/deps/usehooks-ts.ts";

Custom hook that manages a counter with increment, decrement, reset, and setCount functionalities.

Examples

// Usage of useCounter hook const { count, increment, decrement, reset, setCount } = useCounter(5); console.log(Current count: ${count}); increment(); // Increases count by 1 decrement(); // Decreases count by 1 reset(); // Resets count to its initial value setCount(10); // Sets count to 10

Parameters

optional
initialValue: number
  • The initial value for the counter.

Returns

UseCounterOutput

An object containing the current count and functions to interact with the counter.