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

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…

Contents