Intro Custom Hook
(See readme.mdx)Hook: useCount()
Increment with onClick button
useCount
Function increment inside useEffect()
Here some concern about the dependencies array like [increment] dependency on useEffect.This means the increment function will be diferent every time we render. When increment is called, it is going to call setCount.
Means you gonna create the setInterval many times, because it will get clear and it will create again.
Certainly not optimal to clear the interval and set a new one every single time
0
useCount with hook useCallback Better way!
So you have to memoize function increment with useCallback() to be used inside useEffect()
0
Watch Caching for Cash ➔