React HooksLesson 52Free preview
React useCallback
This lesson is part of React · All levels
Summary
UseCallback memoizes the function to not be recreated on each render, as long as its dependence remains unchanged. This is important when the function is passed to the wrapped child component so that the props comparison is not considered to be changed. Use it enough because self-molding has a cost.
Key points
- The shape of the function returns the function
- Useful with the effect of dependency
- The function is recreated only when the value dependency changes
- Over-memoization is actually adding to the complexity of the code.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.