Skip to content

ThemeSwitcher: read the stored theme without setState in an effect #33

Open

Description

@geetxnshgoyal

Problem

components/theme-switcher.tsx:13 sets the active theme in an effect:

useEffect(() => {
    setActive(getStoredTheme());
}, []);

That's an extra render on every page, and react-hooks/set-state-in-effect flags it.

Done when

  • The stored theme is read without a synchronous setState in an effect (for example with useSyncExternalStore, which also keeps several tabs in sync).
  • Switching themes still works and persists across reloads, with no flash or hydration warning.
  • npx eslint components/theme-switcher.tsx is clean.
  • If this is the last open set-state-in-effect issue, also set that rule back to "error" in eslint.config.mjs.

Size: ~15–25 lines.


Taking this? Comment /assign and the bot assigns you if it's free. One issue per person at a time; comment /unassign to hand it back. That's milestone 2 of the 10 PR Journey. Setup and PR steps are in CONTRIBUTING.md. Put Fixes #<this issue> in your PR description.

Activity

  1. swastikkatiyar commented on Oct 8, 2026

    @swastikkatiyar

    /assign

  2. github-actions commented on Oct 8, 2026

    @github-actions

    @swastikkatiyar it's yours! 🎉

    1. Fork the repo and create a branch: see CONTRIBUTING.md.
    2. Open your PR from your fork into main, with Fixes #33 in the description.
    3. Make sure CI (Lint, Test, Type-check & build) is green.

    Can't finish it? Comment /unassign so someone else can pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions