Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use named functions in useEffect
Name effect functions to improve stack traces and make intent clearer during reviews and debugging.
Bad example
| 1 | useEffect(() => { |
| 2 | prefetchSearch(); |
| 3 | }, [query]); |
Explanation (EN)
Anonymous effect functions are harder to identify in stack traces and code reviews.
Objašnjenje (HR)
Anonimne effect funkcije teže je prepoznati u stack traceovima i code reviewu.
Good example
| 1 | useEffect(function prefetchSearchEffect() { |
| 2 | prefetchSearch(); |
| 3 | }, [query]); |
Explanation (EN)
Named effect functions are easier to recognize in stack traces and communicate intent quickly.
Objašnjenje (HR)
Named effect funkcije su lakše prepoznatljive u stack traceovima i brže komuniciraju namjeru.
Exceptions / Tradeoffs (EN)
If the effect is truly trivial (1–2 lines), an anonymous function is acceptable.
Iznimke / Tradeoffi (HR)
Ako je effect zaista trivijalan (1–2 linije), anonimna funkcija je prihvatljiva.