fix: Theme toggle icon resets to System icon on page refresh despite active Dark/Light theme
还没有人认领这个 Issue。
- #270 来自 @puneetnith28 —— 已关闭,未合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- frontend
调研方向
从主题切换触发图标的实现入手,检查 SSR 和 hydration 期间如何使用 currentTheme。添加 issue 中描述的关键行为,然后在刷新页面后验证,持久化的 Dark 和 Light 主题会显示 Moon 和 Sun 图标,而不是 System。
由索引模型根据 Issue 内容生成。
描述
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" />
- 主要语言
- JavaScript
- 星标
- 22
- 派生
- 91
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
webpack/webpack-doc-kit 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 48/100
webpack/webpack-doc-kit#290 · 2 条评论 · 4 个 reaction ·
-
tsc-agenda
难度 3/5 1-2 天 新手友好度 45/100
webpack/webpack-doc-kit#287 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
webpack/webpack-doc-kit#158 · 3 条评论 · 6 个 reaction ·
查看 webpack/webpack-doc-kit 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
babalae/bettergi-scripts-list#3905 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"未关闭
难度 1/5 1-3 小时 新手友好度 87/100
dedicatedcode/reitti#1445 ·
维护者通常 1 天内回复
-
New tool: Uncle Desk可能已有人在做 @github-actions 今天认领。 未关闭submission triage
难度 1/5 1 小时以内 新手友好度 85/100
kausalflow/tools#384 · 1 条评论 ·
维护者通常 1 天内回复
-
good first issue
难度 2/5 1-3 小时 新手友好度 67/100
-
area: css
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复