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 ruleP2universalStack: react
reactmodalsstatedesign-decision
Choose modal mount-vs-isOpen strategy based on desired state lifecycle
Decide consciously between conditional-render (fresh state each open) and an isOpen prop (modal controls its own state); pick per whether you want a clean slate.
PR: hegnar-journalist-boost · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | // no thought given to whether stale state should persist between opens |
| 2 | {open && <ShareModal />} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // want a clean slate each open -> conditional render (intentional) |
| 2 | {open && <ShareModal />} |
| 3 | // want persistent state -> control via prop |
| 4 | <ShareModal isOpen={open} /> |
Explanation (EN)
Objašnjenje (HR)