chore(web): document set-state-in-effect on ThemeToggle localStorage read (#90) #93

Merged
maximus merged 1 commit from issue-90-themetoggle-lint-disable into master 2026-05-30 19:25:21 +00:00
Showing only changes of commit e9ddf27eab - Show all commits

View file

@ -12,6 +12,11 @@ export function ThemeToggle() {
useEffect(() => {
const stored = localStorage.getItem("sl-theme") as Theme | null;
// localStorage is unavailable during SSR, so the stored theme can only be
// read post-mount. ThemeScript already applies the `dark` class before
// hydration (no page FOUC); only the toggle icon corrects on mount. The
// rule is a false positive for this hydration-from-localStorage read.
// eslint-disable-next-line react-hooks/set-state-in-effect
if (stored) setTheme(stored);
}, []);