1
ReactIntermediate#effects#data
Write a function whose name starts with 'use' and which calls other hooks, then return whatever the caller needs. It shares stateful logic, not state — each caller gets its own instance.
function useToggle(initial = false) {
const [on, setOn] = useState(initial);
return [on, () => setOn(o => !o)];
}
const [open, toggle] = useToggle();