How to useCallback() in React Js?

useCallback() is a hook in react js, which is used for the optimization purposes. As we know when the component re-renders all the functions defined inside it, will be created again. To avoid this we have a inbuilt hook, which is useCallback(). It will take two arguments, first is the function and the second is the dependencies array. It basically cache the function definition between different re-renders. In simple words, it will not create the function again and again.:

Leave a Reply

Your email address will not be published. Required fields are marked *