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 introduction

useMemo introduction

Hello and welcome back. Today, we are going to start off with the lesson number seven that is learning about the use memo hook. We have been using the name use memo hook from so many previous lessons in different kind of examples. But I have always been saying you that we are going to learn this in detail in the upcoming lessons. So here we are, useMemoHook of react allows us to memoize the result of a function. You can think of any function and its result that you want to memorize because you don't want that computation to happen again and again. This function computation will only occur when the values of its dependency changes. That's how a basic syntax of useMemo looks like. You get to import the useMemo hook from react. Inside useMemo hook, you can pass on a function. That function can receive multiple arguments or no arguments. And lastly, you have to provide, if necessary, the dependency array containing the dependencies based on which the computation might have to re-effect…

Contents