Coding task · JavaScript and React course · Module 5: useEffect and Custom Hooks
Practice: useDebounce and useToggle
Implement two custom hooks: useDebounce (delaying a value using setTimeout + cleanup) and useToggle (boolean toggle with toggle, setTrue, setFalse functions). useDebounce: useState + useEffect with setTimeout/clearTimeout. useToggle: useState with three state-modifying functions.
Task
Create a custom hook useDebounce(value, delay) returning a debounced value and useToggle(initialValue) returning { value, toggle, setTrue, setFalse }. Both hooks should work with the test components on the page.