fix(use-theme): remove redundant applyTheme from toggleTheme
toggleTheme was calling applyTheme() inside the state updater AND the useEffect was also applying on state change — double DOM write. Now toggleTheme relies solely on the useEffect, matching setTheme behavior.
This commit is contained in:
parent
2688f7e3ca
commit
bb86bf220e
@ -80,10 +80,9 @@ export function useTheme(options?: UseThemeOptions): UseThemeReturn {
|
|||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.localStorage.setItem(storageKey, next);
|
window.localStorage.setItem(storageKey, next);
|
||||||
}
|
}
|
||||||
applyTheme(next, attribute);
|
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
}, [storageKey, attribute]);
|
}, [storageKey]);
|
||||||
|
|
||||||
return { theme, setTheme, toggleTheme };
|
return { theme, setTheme, toggleTheme };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user