You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Handlers should be defined in the lowest component possible, not passed through props
alwaysApply: true
---
# No Callback Props — Colocate Handlers
Do not pass callback functions (click handlers, submit handlers, change handlers, etc.) down through component props. Define handlers in the lowest component that needs them.
- Reduces prop drilling and coupling between components
- Makes components more self-contained and easier to reason about
- Keeps behavior colocated with the UI that triggers it
// ✅ GOOD — handler defined in the component that uses it
function ChildButton() {
const handleClick = () => doSomething();
return (
<button type="button" onClick={handleClick}>
Click
</button>
);
}
```
If shared **state** is needed between siblings, use feature-scoped context or Jotai — not callback props. Do not centralize every mutation in one parent hook; see [`modular-components.mdc`](modular-components.mdc) for complex dialogs and multi-section UI.