useState Hook

By Daniele Di Salvo7d ago (Dec 9, 2025)
react
hooks
javascript

useState Hook

javascript
import { useState } from 'react';

export default function Counter() {
  const [count, setCount] = useState(0);

  function handleClick() {
    setCount(count + 1);
  }

  return (
    <button onClick={handleClick}>
      You pressed me {count} times
    </button>
  );
}

Views

0

Lines

16

Characters

272

Likes

0

Details

Language
Javascript
Created
Dec 9, 2025
Updated
7d ago
Size
0.3 KB

Build your snippet library

Join thousands of developers organizing and sharing code snippets.