1 2 3 4 5 6 import { CodeBlock } from './CodeBlock' export function Basic() { return <CodeBlock source="./counter/useCounter.ts" /> }
import { CodeBlock } from './CodeBlock' export function Basic() { return <CodeBlock source="./counter/useCounter.ts" /> }
import { useState } from 'react' export function useCounter(initialValue: number = 0) { const [count, setCount] = useState(initialValue) return { count, increment: () => setCount(count + 1), decrement: () => setCount(count - 1), } }