*useCallback *
-> It remembers a new reference while the re-renders
-> It returns the same reference value when the depedency array values are not changed
-> When depedency values changes it creates a new function reference
eg:
const display = useCallback(() => {
console.log(count);
}, [count]);
count same → same function reference
count changed → new function reference
react compare the previous value {count} and the current value {count}
Top comments (1)
xd