Sale

The past few weeks have brought a lot of change all over the world. Here at Level Up, we hope you're taking appropriate actions to protect yourself and those around you from the spread of COVID-19. Because many of you are stuck at home, we've put all courses and the yearly subscription (Level Up Pro) 50% off until you unsubscribe.
Stay safe. - Scott Tolinski

Save 50%

$12/month*

*Paid annually

card background pattern
Level 2

Custom React Hooks

Unlock Full Course

$49.99 $24.99

Or

$24.99/Month

A Basic Toggle Hook

We will start off looking at hooks by making a basic toggle using React hooks. We will use the useState hook to accomplish this.

Downloads

Comments

fpigeonjr
20 days ago

Scott, what font and theme are you using? Looks great!

dave.js
2 months ago

@Daniel The intention is to avoid potential bugs when introducing async functionality into the component. Here's a section in the FAQs that gives an example of this: https://reactjs.org/docs/hooks-faq.html#why-am-i-seeing-stale-props-or-state-inside-my-function

Daniel
2 months ago

do you have a link to the recommendation of prevState over the state variable? i couldn't find it in the react docs where they just use the regular state variable

Ryan C. Perry
2 months ago

In the same VSCode package, RAFCE does the same thing with the default export at the bottom.

Something to say?

Become a Pro