Skip to content

fix: prevent dark mode flicker during SPA navigation#573

Open
saurabhhhcodes wants to merge 1 commit into
indresh404:mainfrom
saurabhhhcodes:fix/dark-mode-flicker-558
Open

fix: prevent dark mode flicker during SPA navigation#573
saurabhhhcodes wants to merge 1 commit into
indresh404:mainfrom
saurabhhhcodes:fix/dark-mode-flicker-558

Conversation

@saurabhhhcodes

Copy link
Copy Markdown

Fixes #558

Root cause

The body had transition-colors duration-300 which made color/background changes visible as a 300ms animation. Combined with useEffect (async, after paint) for theme syncing, this caused a visible white flash during page navigation.

Changes

  1. Removed transition-colors duration-300 from body — prevents visible color transitions that caused the flash
  2. Switched useEffectuseLayoutEffect — theme class is applied synchronously before browser paint

The blocking script in index.html already applies the dark class before React mounts; these changes ensure zero flicker during SPA navigation as well.

- Remove transition-colors from body to prevent visible theme transitions
- Use useLayoutEffect instead of useEffect for synchronous DOM updates
- Prevents the white flash when navigating between pages in dark mode
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ranker-hub Ready Ready Preview, Comment Jun 17, 2026 7:28am

@github-actions github-actions Bot added bug Something isn't working frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dark mode flickers to light mode for a split second on every page navigation

1 participant