Component extraction cover

When to Extract a Component (and When to Just Copy-Paste)

Early in building Polaris, I extracted a ConfirmDialog component after using it exactly once. I figured I’d need it everywhere — deletes, password changes, dangerous actions. Classic foresight. Then the second use case needed a text input inside the dialog. The third needed two buttons with custom labels instead of “Confirm/Cancel”. The fourth needed async validation before confirming. Within a month, my clean ConfirmDialog had 8 props, 3 slots, and a mode prop that changed its behavior entirely. ...

February 12, 2025 · 3 min · Muhammad Hassan Raza