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 Practice Hooks in React !
You have completed Practice Hooks in React !
Preview
Complete the final challenge using the `useContext`, `useState` and `useHistory` hooks.
Switch Statement
switch (event.target.name) {
case "name":
setName(value);
break;
case "username":
setUser(value);
break;
case "password":
setPass(value);
break;
default:
return;
}
Treehouse Course on switch statements
if else
if (event.target.name === 'name') {
setName(value);
}
else if (event.target.name === 'userName') {
setUser(value);
}
else if (event.target.name === 'name') {
setPass(value);
}
else {
return;
}
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
We can delete Component since
we won't use that anymore.
0:00
Then we can import useHistory along
with Link from react-router-dom.
0:09
Let's clean up the class syntax,= and
replace the word class with function.
0:16
I will delete this as well,
And add parentheses here.
0:24
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