From the course: React: Advanced Code Challenges

Unlock this course with a free trial

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

Avoiding expensive computations

Avoiding expensive computations - React.js Tutorial

From the course: React: Advanced Code Challenges

Avoiding expensive computations

- [Instructor] So since React 16.8, developers can write stateful components without having to write a class. So the hooks lets you use states and lifecycle logic inside functional components. So first, you know about useStates that we use to define local state inside functional components. And you have also useEffect to apply side effects inside functional components. You also have useContext to create and share global states across components in the application tree. Then we use, for optimization purposes, useMemo. This is to create derived data and memoized value from objects, and to cache results from previous renders and avoid expensive calculations. So useMemo is for objects. Then you have also useCallback, which is a React hook that we use also to cache the results for functions between re-renders and avoid expensive computations. All right, so let's go find our example here. So we're going to go up here. So we have this list that we want to display, and we have these…

Contents