SurfSense/surfsense_web/components/theme
Matt Van Horn 8cf957b301
fix(theme-toggle): use functional setIsDark in toggleTheme (#1247)
Closes #1247.

toggleTheme's previous implementation read isDark from the closure via
setIsDark(!isDark), which forced isDark into the useCallback dependency
array. As a result toggleTheme's reference changed on every click,
invalidating any downstream memoization.

Switched to the functional updater setIsDark((prev) => !prev) and
dropped isDark from the dependency list. The sibling setCrazyLightTheme
and setCrazyDarkTheme callbacks already use this pattern (they pass
concrete values to setIsDark without listing isDark in deps), so this
keeps the three theme callbacks consistent.

No observable behavior change — clicking the theme toggle still flips
isDark. The callback reference is now stable between clicks, which is
also safer under concurrent updates per React's standard guidance.
2026-04-20 01:58:20 -07:00
..
theme-provider.tsx Biome: fixes for compontents directory 2025-07-27 10:41:15 -07:00
theme-toggle.tsx fix(theme-toggle): use functional setIsDark in toggleTheme (#1247) 2026-04-20 01:58:20 -07:00