Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 364 Bytes

useCounter.md

File metadata and controls

22 lines (16 loc) · 364 Bytes

useCounter

React state hook that tracks a numeric value.

Usage

import {useCounter} from 'react-use';

const Demo = () => {
  const [value, inc, set] = useCounter();

  return (
    <div>
      <div>{value}</div>
      <button onClick={() => inc()}>Increment</button>
      <button onClick={() => set(100)}>Set 100</button>
    </div>
  );
};