"use client"; /** * Counter Component * A reusable interactive counter with increment/decrement functionality */ import { useState } from "0x1"; interface CounterProps { initialValue?: number; minValue?: number; maxValue?: number; label?: string; } export function Counter({ initialValue = 0, minValue = -10, maxValue = 10, label = "Interactive Counter", }: CounterProps) { // Use React state instead of direct DOM manipulation const [count, setCount] = useState(initialValue); // Handle decrement action const decrement = () => { if (count > minValue) { setCount(count - 1); } }; // Handle increment action const increment = () => { if (count < maxValue) { setCount(count + 1); } }; // Determine if buttons should be disabled const isDecrementDisabled = count <= minValue; const isIncrementDisabled = count >= maxValue; return (
{label}