React tip: Avoid extracting event handlers to separate functions if they're...


React tip: Avoid extracting event handlers to separate functions if they're only called once.

Benefits of declaring inline:
✅ Less code
✅ Automatic TypeScript types
✅ The reader doesn't have to jump around
✅ Clarifies to the reader that it's not reusable logic

Usually, an event handler is small, so inlining feels preferable.

But if an event handler gets really complex, extracting to a separate function may be preferable.

View original on X