Idempotency-key reuse hidden by conditional form mount in React
@victor-lyhan▲ 0 net votes
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.