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.
Learn event handling and updating the state
From the course: Building Production-Ready React Apps: Setup to Deployment with Firebase
Learn event handling and updating the state
- [Instructor] In order to get started with the hooks, let's take a first look at useState. So we're going to start by importing it from the React Library. And it's going to be useState, so we must make sure that this is added to the scope of this component app. And so the goal here is to transform this functional component into a stateful functional component. So we're going to go inside and we're going to use this syntax with useState. It's going to return an array. So first is a local variable to return the current state, and second is the function that we use to update the state. And as we saw previously, you can always pass an initial state. So we're going to use that, so instead of accessing photos outside of the component, because we can never access any update, we're going to refer to items, because now we can handle the logic from within the components. So we're going to check this out. So for now, this is giving…
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
-
-
-
-
-
-
-
-
-
-