From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Validate and submit forms: useMemo
From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Validate and submit forms: useMemo
- [Instructor] useMemo is another React Hook that returns a memoized value and only recomputes the memoized value when there is a change in the state in the list of dependencies, right here. You can see that the syntax is very similar to useEffect. First, it creates a function and the second parameter is an array with a list of dependencies. So why we use useMemo? It allows to help with performance and avoid expensive computations on every render, meaning that the value is only recalculated if there is a change in the state. Otherwise, it's going to return a memoized value. So let's see what we want to do here. So we want to prevent the user to submit the form if there is any data missing. So for now, I can submit anything and it's still going to work. We want to prevent that. So there are a few changes to do here. So first, we're going to go to UploadForm. Right here and we're going to make sure that we pass the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Introduction to Hooks API Reference2m 52s
-
(Locked)
Learn event handling and updating the state4m 12s
-
(Locked)
Handle conditional rendering3m 47s
-
(Locked)
Work with forms4m 1s
-
(Locked)
Submit the form and apply side effects: useEffect5m 32s
-
(Locked)
Validate and submit forms: useMemo6m 11s
-
(Locked)
Handle complex logic with useReducer5m 34s
-
(Locked)
Create and dispatch actions4m 37s
-
(Locked)
Compose and update the UI6m 1s
-
-
-
-
-
-
-
-
-
-