{
  "id": 15601878,
  "title": "Twelve confirmations behind a 50 line hook, and not one of them returns a promise",
  "url": "https://urgent.news/2026/10/19/twelve-confirmations-behind-a-50-line-hook-and-not-one-of-them",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-19T12:19:03.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/daniel_pertu/twelve-confirmations-behind-a-50-line-hook-and-not-one-of-them-returns-a-promise-3n43"
  },
  "original_language": "en",
  "account": "Twelve different components in the Nakodo application utilize a 50-line confirmation dialog hook, but none of them actually fulfill their intended purpose. The hook, named `useConfirm`, allows for creating a single confirmation dialog per component while it is animating out. To open the dialog, the `confirm` function is called with an object containing the question text, description, action button label, whether the action is destructive, and the function to run if the user confirms.\n\nThis hook is used in four components, with a total of twelve call sites. Despite its simplicity, the hook has a few issues that make it less than ideal for use. First, the dialog may never resolve a promise, leaving the code after the await statement incomplete. This is problematic when there is cleanup or transitions involved in the process. Secondly, the dialog keeps its text open even after it has been closed, which can cause confusion and an unprofessional appearance.\n\nIn order to resolve these issues, the author suggests using the `run` function to keep the Server Action call lexically inside the component that owns the pending state. This way, the click on the confirm button is the start of the transition, rather than a continuation resumed later in the handler. Additionally, the author acknowledges that sequential flows would be more convenient with promises, but in the current implementation there are no sequential flows. The dialog also keeps its text open after closure, which can cause visual bugs and a poor user experience.",
  "summary": "Twelve places in Nakodo ask \"are you sure\". They all go through this: export type Ask = { title : string ; text : string ; action : string ; // the confirm button cancel ?: string ; destructive ?: boolean ; run : () => void ; }; // One confirmation dialog per component, kept filled while it animates out. // Render `dialog` anywhere in the component and call `confirm` to open it. export function…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}