← Back to snippets

React useState Hook

by bobDecember 19, 2025 at 03:45 PM93 viewsjavascript
import { useState } from 'react';

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

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
    </div>
  );
}

export default Counter;
Create New SnippetBack to Home