Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Include every reactive value read by an effect
List all reactive values the effect reads in its dependency array, even if you believe they never change, to follow the rules of hooks.
Bad example
| 1 | useEffect(() => { |
| 2 | if (isLoggedIn) inject(codes); |
| 3 | }, []); |
Explanation (EN)
The effect reads login state and codes but never reacts when they change.
Objašnjenje (HR)
Good example
| 1 | useEffect(() => { |
| 2 | if (isLoggedIn) inject(codes); |
| 3 | }, [isLoggedIn, codes, inject]); |
Explanation (EN)
Include inject if it comes from component props or scope; an imported stable inject function need not be listed.
Objašnjenje (HR)
Notes (EN)
Include the reactive values actually read by an effect, using the configured hooks linter and tracing functions captured from the component scope.
Exceptions / Tradeoffs (EN)
Stable setters, refs, imported functions and other proven nonreactive values do not require redundant dependencies. Restructure the effect instead of suppressing a real dependency.