React
Introduction to React Hooks - useState()
  •  

Introducing useState()

Outline

Convert class-based components into functional ones and manage state with the useState hook.

https://stackblitz.com/edit/reacthooks-1-usestate-ido

You have to follow a series of steps to implement the useState hook on your component here:

1️⃣ You need to convert our class-based component to a functional component

2️⃣ You need to import the useState hook and assign the desired state using the function

3️⃣ You have to remove all references to setState and use the functions that the useState hook returns to you to handle updates to the state

After going through these steps:

1️⃣ You have less code for cleaner programming

2️⃣ Your syntax is easier to read

3️⃣ You no longer have to deal with the confusion of the 'this' keyword

 

I finished! On to the next chapter