Summary
Fix the theme toggle icon resetting to the System icon after page refresh.
Issue
The selected theme is saved correctly, but after refreshing the page, the toggle still shows the System icon instead of the Sun or Moon icon.
Root Cause
During SSR, the System icon is rendered by default. During Preact hydration, the existing SVG is reused instead of being replaced with the correct theme icon.
Proposed Fix
Add a key={currentTheme} prop to the trigger icon so Preact's reconciler cleanly replaces the stale server-rendered SVG node during client hydration:
<TriggerIcon key={currentTheme} height="20" />
Summary
Fix the theme toggle icon resetting to the System icon after page refresh.
Issue
The selected theme is saved correctly, but after refreshing the page, the toggle still shows the System icon instead of the Sun or Moon icon.
Root Cause
During SSR, the System icon is rendered by default. During Preact hydration, the existing SVG is reused instead of being replaced with the correct theme icon.
Proposed Fix
Add a
key={currentTheme}prop to the trigger icon so Preact's reconciler cleanly replaces the stale server-rendered SVG node during client hydration: