Urgent.News

What's breaking now, across thousands of outlets.

Tech

Twelve confirmations behind a 50 line hook, and not one of them returns a promise

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…

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.

This 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.

In 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.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Vibe Coding" is driving real software engineers insane

Let’s be honest about the current state of software development. Over the past few months, the tech industry has fallen in love with a new term: "Vibe Coding." People with zero engineering background…

  • "Vibe Coding" involves non-engineers generating code via AI prompts
  • Senior engineers disregard core software principles, focus on intuition
  • Real software engineers spend time fixing "vibe code" and its issues

Is my S3 bucket HIPAA compliant? The question AWS can't answer

✓ Human-authored analysis; AI used for formatting and proofreading. Recurring theme on r/aws: "I'm storing PHI in S3. I enabled encryption, turned on logging, set the bucket to private.

  • HIPAA Security Rule outlines four safeguard categories for ePHI storage.
  • AWS Key Management Service enables encryption at rest for S3 buckets.
  • Stave CLI tool assesses S3 configurations against HIPAA compliance.

More from Monday 19 October →