Merge pull request 'chore(web): document set-state-in-effect on ThemeToggle localStorage read (#90)' (#93) from issue-90-themetoggle-lint-disable into master

This commit is contained in:
maximus 2026-05-30 19:25:20 +00:00
commit 51429045e6

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);
}, []);