Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP0universalStack: react
asyncconcurrencyformscorrectness
Guard async submit actions against double-submission
Track in-flight state for every async submit path and disable the trigger while a request is pending, so a double-click or method switch can't fire concurrent submissions.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | const onConfirm = () => { |
| 2 | form.handleSubmit(submit)(); // unawaited, no loading flag for this path |
| 3 | }; |
| 4 | <Button onClick={onConfirm}>Confirm</Button> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const [isSubmitting, setSubmitting] = useState(false); |
| 2 | const onConfirm = async () => { |
| 3 | setSubmitting(true); |
| 4 | try { await form.handleSubmit(submit)(); } |
| 5 | finally { setSubmitting(false); } |
| 6 | }; |
| 7 | <Button onClick={onConfirm} disabled={isSubmitting}>Confirm</Button> |
Explanation (EN)
Objašnjenje (HR)