In this lab, you'll update state using setState()
.
We got a new job! Woo! This time, we're a judge for Guinness World Records. We're no ordinary judge, however — we're a modern day judge. We do things using computers. Instead of using those old, clunky clickity-things to count stuff for world records, we'll write our very own digital clicker!
- In the
components/DigitalClicker.js
file, create aDigitalClicker
React component. - This component has a state property called
timesClicked
, that is initially defined as 0. - The component renders out a button with a label that shows the
timesClicked
value. This means that at the start, your button should just say0
. - Whenever the button is clicked, update the state by incrementing the
timesClicked
by 1.
You can only count so many jumps, hula-hoop rotations and hot dogs being devoured before you go insane. Time to move on from our record judge job to greener pastures! Not to worry, we've secured ourselves a gig at YouTube this time! Our first task is to create some sort of debug bar that allows us to control the simulated network conditions on YouTube. Among other things, we can change our resolution, the bitrate of the videos, the audio quality, and so on.
- In the
components/YouTubeDebugger.js
file, create aYouTubeDebugger
React component. - This component has several state properties, the initial shape looks like this:
{
errors: [],
user: null,
settings: {
bitrate: 8,
video: {
resolution: '1080p'
}
}
}
- Create a button with the class
'bitrate'
. Clicking this button changes thesettings.bitrate
state property to12
. - Create a button with the class
'resolution'
. Clicking this button changes thesettings.video.resolution
state property to'720p'
.
Note: the classes are added to make testing your solution a little easier.