Great Effort !! brother 😁
I don't have much experience with useCallback,
Can you please explain this
How callback will detect that setLocation is changed !!
setLocation is just setter funciton right.
Thanks for pointing this out! You are correct! We don't need to pass setLocation here in the callback dependencies as it won't change. Will update the post now, thank you!
I am a Full Stack Developer with over 10 years of professional experience, specializing in designing, developing, and deploying robust, scalable web applications. My expertise spans a wide range of Ja
Great Effort !! brother 😁
I don't have much experience with useCallback,
Can you please explain this
How callback will detect that setLocation is changed !!
setLocation is just setter funciton right.
Thanks for pointing this out! You are correct! We don't need to pass setLocation here in the callback dependencies as it won't change. Will update the post now, thank you!
useCallback() hook is used to capture the whole function just a way to optimize the performance like as memoisation.
useCallback() used in conjunction with useEffect() because it allows you to prevent the re-creation of a function.
I hope this information helps you in understanding the useCallback() hook in react.
@Cheers
adnanaslam
Thanks brother!!