Custom Hooks
A custom hook is a function starting with use that calls other hooks.
Example
function useToggle(initial = false) {
const [on, setOn] = useState(initial);
const toggle = () => setOn((o) => !o);
return [on, toggle];
}Exercise
Naming rule.
function Toggle() {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.