Counter Example

13 January 2021 - 1 min read

Click on the button to increment the counter.

import { useState } from "react";

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

  return (
    <button
      className="w-16 px-4 py-2 rounded-lg !bg-black  text-slate-900"
      onClick={() => setCount(count + 1)}
    >
      {count}
    </button>
  );
}