MCPcopy Create free account
hub / github.com/react/react / useCount

Function useCount

packages/react-reconciler/src/__tests__/useEffectEvent-test.js:488–495  ·  view source on GitHub ↗
(incrementBy)

Source from the content-addressed store, hash-verified

486 }
487
488 function useCount(incrementBy) {
489 const [count, updateCount] = useState(0);
490 const increment = useEffectEvent(amount =>
491 updateCount(c => c + (amount || incrementBy)),
492 );
493
494 return [count, increment];
495 }
496
497 function Counter({incrementBy}) {
498 const [count, increment] = useCount(incrementBy);

Callers 1

Calls 2

useStateFunction · 0.50
useEffectEventFunction · 0.50

Tested by

no test coverage detected