Advanced React

Join the React Bootcamp

The React Bootcamp is 5 full weeks of professional React training to take you from wherever you are to top-tier React programmer in record time.

Lifetime Access

Complete Package

Refs and Rendering

Fix this code so that the toggle component works and successfully toggles the Switch when clicked.

Note that you need to implement a different way to use state in React.

This lesson is part of the full version of the React Bootcamp. Already joined? Log in here


References in React can store values.

Here in this toggle component, I'm using ref and passing it a default value of false and calling this ref toggle ref, I'm going to link it to this enabled variable.

If enabled is true, the toggle switch is enabled. If false, then it's not switched on. So appl...