Bug
Problem
The hook accesses window.matchMedia inside an effect without checking whether window exists.
Optional chaining does not prevent a crash when window itself is undefined.
Impact
- Runtime error in SSR environments.
- Reduced portability and testability.
Location
src/utils/usePrefersReducedMotion.ts
Suggested Fix
- Add a guard at the top of the effect:
- Exit early if
typeof window === "undefined".
- Then safely use
window.matchMedia(...).
Bug
Problem
The hook accesses
window.matchMediainside an effect without checking whetherwindowexists.Optional chaining does not prevent a crash when
windowitself is undefined.Impact
Location
src/utils/usePrefersReducedMotion.tsSuggested Fix
typeof window === "undefined".window.matchMedia(...).