I am studying React, and I am stuck on understanding the benefits of useCallback
hook. According to this website,
In function components, the execution of the whole function is the equivalent of the render function in class components.
If in the functional components, the whole function is executed on every render, doesn't that mean that the whole code would be re-executed afresh. As a result the useCallback
hook would start from a clean state on each render, meaning that useCallback
cache would be reinitialized and all previous cache entries would be lost?