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: React
reactside-effectsurlcomponent-design
Reusable components must not mutate the page URL or global history
A component meant to be dropped onto arbitrary pages should keep its state internal; pushing to window.history on interaction leaks side effects onto the host page.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const handleTabChange = (tab) => { |
| 2 | setActiveTab(tab); |
| 3 | window.history.pushState({}, '', `/news/${tab}`); // affects host page URL |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const handleTabChange = (tab) => { |
| 2 | setActiveTab(tab); // internal state only |
| 3 | fetchData(tab); |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)