You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useColorMode's default onChange function is triggered as soon as the composable is called. Unless the disableTransition: false option is used, the page will reflow and negatively impact performance on complex pages.
The onChange function will be triggered once per useColorMode usage whenever we toggle the dark mode, triggering a reflow each time.
This also affects useDark since it directly uses useColorMode.
Two mitigating solutions until this is fixed:
Use useDark and useColorMode once and share the ref across the app to avoid unnecessary calls to the onChange functions. This is not possible whenever a library uses the composable.
Use disableTransition: false to avoid page reflows, but then again, if a library doesn't use the option, we have the same problem.
Potential fixes I can think of:
Do not call the onChange function on usage
Do not call the onChange function if nothing changed
Do not register the same onChange function multiple times
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
Check that this is a concrete bug. For Q&A open a GitHub Discussion.
Describe the bug
The bug has two parts:
useColorMode
's default onChange function is triggered as soon as the composable is called. Unless thedisableTransition: false
option is used, the page will reflow and negatively impact performance on complex pages.useColorMode
usage whenever we toggle the dark mode, triggering a reflow each time.This also affects
useDark
since it directly usesuseColorMode
.Two mitigating solutions until this is fixed:
useDark
anduseColorMode
once and share the ref across the app to avoid unnecessary calls to the onChange functions. This is not possible whenever a library uses the composable.disableTransition: false
to avoid page reflows, but then again, if a library doesn't use the option, we have the same problem.Potential fixes I can think of:
Reproduction
Not required
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: