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.

useState hook

useState hook

Hello and welcome to lesson number 2. In this lesson, we'll discuss about the useState hook in great detail. As you know that so far we have covered the useState hook. But we are going to do in-depth analysis of what's remaining and what are the items that we should be careful about when we are using the useState hook. On the whole, it depends on three main factors. The first is that how we are going to do the functional updates using the updater function. You will be around 90% covered on this part, but we are going to revisit what we have learned so far and we'll add some new additions to that. Next we have is lazy initialization for expensive initial state. Over here we'll discuss that what lazy initialization is and why we should use it when we have a complex state options. Lastly, we'll see how we can use objects and arrays in our useState hook. So let's revisit and see that what UState is. We know that this is a React hook which allows us to keep state values. So far, we have…

Contents