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
lifecycleside-effectsauthcorrectness
Trigger user-data side effects on the correct lifecycle event
Choose the hook/callback that fires for every relevant scenario. For example, sending user data on page visit vs. only on login changes who it covers; verify both the already-logged-in and just-logged-in paths fire the intended code.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | // only inside loginSuccess: misses users already logged in on page load |
| 2 | loginSuccess: () => { mixpanelUserProps(); } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // fire on script load (covers already-logged-in) AND on loginSuccess (covers fresh login) |
| 2 | scriptLoaded: () => { mixpanelUserProps(); } |
| 3 | loginSuccess: () => { mixpanelUserProps(); } |
Explanation (EN)
Objašnjenje (HR)