Skip to content

Why can mounting a React screen accidentally submit the same creative action twice?

Do not submit paid generation merely because a component mounts or an effect runs. Trigger submission from an explicit application command with a durable action identity. React development checks can run an extra setup and cleanup cycle, exposing effects whose behavior depends on running only once.

DESIGN A CLEAR API PRODUCT EXPERIENCEAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Find mutation-bearing effects; Keep commands durable; Test remount behavior.
Workflow diagram: Find mutation-bearing effects → Keep commands durable → Test remount behavior. Read the article for evidence and limits.

Rendering is not a spending decision

A page may mount again after navigation, error recovery or a framework development check. Those events synchronize UI state; they do not establish a new user intention to purchase work. A ref that suppresses a second effect run does not define a durable business action.

What to do next

  1. 01

    Find mutation-bearing effects

    Review effects that call your backend create route rather than merely reading task status. Move generation into a command invoked after the user approves the exact creative request, leaving effects to subscribe or fetch.

  2. 02

    Keep commands durable

    Give the approved action a stable application identity before dispatch. Repeated delivery of that command should resolve to the same local action, while a deliberate new creative attempt receives a different identity.

  3. 03

    Test remount behavior

    Run the screen under development checks, navigate away and back, and recover an error boundary. Confirm these lifecycle changes only reconnect to existing task state and never create another approved action.

A concrete example

Illustrative example: a result page mounts twice in development. Its effect reads task 82 twice, which is harmless to creative intent. The only create command remains the one recorded when the user pressed Generate on the approval screen.

Before you call it ready

  • Inspect effects for create requests.
  • Remount before the first response.
  • Verify navigation does not create an action.

When to stop or choose another method

Stop automatic dispatch if the only evidence of user intent is component mounting; require the application's existing explicit approval command.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation