scrimba
Frontend Career Path
Advanced React
Reusability
Custom Hooks - useToggle part 3
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Custom Hooks - useToggle part 3
AboutCommentsNotes
Custom Hooks - useToggle part 3
Expand for more info
components
Star.js
run
preview
console
import React from "react"
import Toggle from "./Toggle/index"
import { BsStar, BsStarFill } from "react-icons/bs"

/**
* Challenge: Remove all parts of our Toggle component
* (don't delete the react-icons stars though!) and use
* the useToggle hook to conditionally render the stars.
* Make sure to add an onClick that runs the `toggle` function
* you get from useToggle()
*/

export default function Star({ onChange }) {
return (
<Toggle onToggle={onChange}>
<Toggle.Button>
<Toggle.On>
<BsStarFill className="star filled" />
</Toggle.On>
<Toggle.Off>
<BsStar className="star" />
</Toggle.Off>
</Toggle.Button>
</Toggle>
)
}
Console
/index.html
-2:57