pacocoursey / next-themes

Perfect Next.js dark mode in 2 lines of code. Support System preference and any other theme with no flashing
https://next-themes-example.vercel.app/
MIT License
4.68k stars 169 forks source link

fix: setTheme now works correctly when a function is passed. #286

Closed trm217 closed 2 months ago

trm217 commented 2 months ago

Description

Fixes #277. The dependencies of the set-state function, that is a useCallback hook it's self were faulty. This PR defined 'theme' as a dependency of the callback-hook and removes 'forcedTheme' from the dependency. Additionally a test-case has been added where setState is called with (theme) => theme === 'light' ? 'dark' : 'light')

This PR is based on: #285

Commits

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-themes-basic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 4:04pm
next-themes-tailwind ❌ Failed (Inspect) Apr 24, 2024 4:04pm
next-themes-with-app-dir ❌ Failed (Inspect) Apr 24, 2024 4:04pm