scrimba
Frontend Career Path
Advanced React
Reusability
Custom Hooks - useToggle
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

AboutCommentsNotes
Custom Hooks - useToggle
Expand for more info
hooks
useEffectOnUpdate.js
run
preview
console
import React from "react"

export default function useEffectOnUpdate(effectFunction, deps) {
const firstRender = React.useRef(true)

React.useEffect(() => {
if (firstRender.current) {
firstRender.current = false
} else {
effectFunction()
}
}, deps)
}
Console
/index.html
-4:45