function eventHandler(...fns) {
return (e) => {
fns.forEach(fn => fn(e);
}
}
function Component({ onClick )) {
const handler = useClickable();
return <div onClick={eventHandler(handler, onClick)} />
}
// Or you could do this:
function eventHandler(event, ...fns) {
fns.forEach(fn => fn(event);
}
function Component({ onClick )) {
const handler = useClickable();
return <div onClick={event => eventHandler(event, handler, onClick)} />
}
Created
December 14, 2021 02:35
-
-
Save alanbsmith/eabea04a56dd39fd7bce2ae6167c18bd to your computer and use it in GitHub Desktop.
function iterator
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment