All files / src/components components.tsx

0% Statements 0/5
100% Branches 0/0
0% Functions 0/4
0% Lines 0/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                                 
import { useState } from 'react'
 
/**
 * A minimal counter component that demonstrates basic React state handling.
 *
 * Maintains an internal count value and provides buttons to increment and reset it.
 *
 * @returns A JSX element rendering the counter UI.
 */
function Counter() {
  /** The current counter value. */
  const [count, setCount] = useState(0)
 
  return (
    <div className="card">
      <button onClick={() => setCount((count) => count + 1)}>
        count is {count}
      </button>
      <button className='reset' onClick={() => setCount(0)}>
        Reset Counter
      </button>
    </div>
  )
}
export default Counter