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 ruleP1universalStack: Web APIs / React
progressive-enhancementdryweb-apiux
Use one handler with graceful fallback instead of duplicating UI per device
When a native capability may be unavailable (e.g. navigator.share), call it and fall back to a custom UI on failure rather than branching into duplicated components and handlers per viewport.
PR: abcn-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | // separate mobile and desktop share components + handlers |
| 2 | if (isMobile) return <MobileShareButton />; |
| 3 | return <DesktopShareModalButton />; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const handleShare = async () => { |
| 2 | try { |
| 3 | await navigator.share(shareData); |
| 4 | } catch { |
| 5 | openCustomShareModal(); // fallback for non-share contexts |
| 6 | } |
| 7 | }; |
Explanation (EN)
Objašnjenje (HR)