Skip to content

Instantly share code, notes, and snippets.

@dkacper
Created June 5, 2025 08:53
Show Gist options
  • Save dkacper/e49435b394cb5e9ab9246c373826d2e6 to your computer and use it in GitHub Desktop.
Save dkacper/e49435b394cb5e9ab9246c373826d2e6 to your computer and use it in GitHub Desktop.
Compose handlers of your react component.
export const composeHandlers = (...handlers: unknown[]) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (...args: any[]) => {
for (const handler of handlers) {
if (typeof handler === 'function') {
handler(...args);
}
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment