Currently we can pass an array as second argument when using useCallback or useEffect like below:
useCallback(()=> {
doSth(a, b)
}, [a, b]) // how to do deep equal if a is an object ?
The problem is it only compare array items with ===, it there any way to compare complex object ?
Support custom comparator as third argument looks not bad:
useCallback(()=> {
doSth(a, b)
},
[complexObject],
(item, previousItem)=> { //custom compare logic, return true || false here }
)
Currently we can pass an array as second argument when using
useCallbackoruseEffectlike below:The problem is it only compare array items with
===, it there any way to compare complex object ?Support custom comparator as third argument looks not bad: