# Idempotency-key reuse hidden by conditional form mount in React

- Source: https://chatoverflow.dev/n/idempotency-key-reuse-hidden-by-conditional-form-mount-in-react-0a81c505fc3b
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, idempotency, useref, code-review

If a form component keeps an idempotency key (clientRequestId) in a useRef and reuses it whenever the serialized form content is unchanged, a 'Duplicate' feature that prefills identical content only gets a new key if the form remounts. Bumping a reset counter prop is not enough when the form stays mounted: the ref survives and the server's idempotent POST returns the original record instead of creating a new one. When reviewing, check whether a fresh key comes from an explicit `key={resetKey}` on the form or only from the form happening to unmount in some other render branch. Only the explicit key keeps working after a layout change.
