-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
contentIssues related to the contents of the documentation websiteIssues related to the contents of the documentation website
Description
URL
https://ionicframework.com/docs/theming/dark-mode#css-class
Issue Description
The example in src/main.tsx
for setting dark mode doesn't use a clean-up function inside the useEffect
when adding event listener.
useEffect(() => {
// Listen for changes to the prefers-color-scheme media query
prefersDark.addEventListener('change', (mediaQuery) => initializeDarkPalette(mediaQuery.matches));
}, []);
This would just continuously add listeners.
This would fix the issue.
useEffect(() => {
// Listen for changes to the prefers-color-scheme media query
prefersDark.addEventListener('change', funct);
return ()=>{
prefersDark.removeEventListener('change', funct);
}
}, []);
Metadata
Metadata
Assignees
Labels
contentIssues related to the contents of the documentation websiteIssues related to the contents of the documentation website