Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed React Basics!
You have completed React Basics!
Preview
In this video, we'll add state to a component by using the useState Hook in the Counter component
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Remember, in React the state
can change over time,
0:00
usually based on what a user does.
0:00
So what's going to change in our Counter
component when users interact with it?
0:03
Well, it's the quantity,
it will increase or
0:08
decrease depending on
which button they click.
0:11
Quantity is our state.
0:14
To add a state variable to your component,
you'll need to use the useState hook.
0:16
In React, useState,
0:22
as well as any other functions
starting with use, is called a hook.
0:24
Hooks are special functions that let
you hook into different React features.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up