This is a lot more code than you need. Taking your original sample, put value into a ref from useRef, and inside the useCallback function, get value from your ref. Also, don't use [value] as a dependency, use only [] dependencies, this way it only runs once.
This is a lot more code than you need. Taking your original sample, put
value
into a ref fromuseRef
, and inside theuseCallback
function, getvalue
from your ref. Also, don't use[value]
as a dependency, use only[]
dependencies, this way it only runs once.