This PR wraps removeItem with useCallback to preserve its reference in most use cases.
Currently, removeItem does not have a stable reference. It is being re-initialized every time a value is changed. This is suboptimal, because calling removeItem should not re-initialize itself.
An example use case would be using it in a useEffect:
This PR wraps
removeItem
withuseCallback
to preserve its reference in most use cases.Currently,
removeItem
does not have a stable reference. It is being re-initialized every time avalue
is changed. This is suboptimal, because callingremoveItem
should not re-initialize itself.An example use case would be using it in a
useEffect
:While obviously there are ways to mitigate that, do extra checks etc., maintaining references as stable as possible should reduce possible bugs.