From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

useMemo dos and don'ts: Summary

useMemo dos and don'ts: Summary

Welcome back, now let's see when we should not be using the USEMEMO hook. This is actually pretty important that we should know that when a hook is going to be useful or not. So USEMEMO is used for performance optimization. It's not a correctness tool. If you have made a mistake and your profiling shows you unusual results, you have to be very careful that whether there is an optimization required or something that you are doing terribly wrong that is actually messing up the performance of your component. This use memo is a memorization of the result of a pure function. So pure functions are when whatever input you are going to give them, they are going to return you the same output on that particular input. So based on this definition, we have to be careful of when we should be using the use memo hook. So you should avoid using the use memo hook when you have small and cheap computations. Use memo is efficient and needed when you have an expensive calculation to do. Not for a small…

Contents