Skip to content

Instantly share code, notes, and snippets.

@AhmetEnesKCC
Last active March 19, 2022 13:29
Show Gist options
  • Save AhmetEnesKCC/e40f754c223b64cf9d25eb471c75119a to your computer and use it in GitHub Desktop.
Save AhmetEnesKCC/e40f754c223b64cf9d25eb471c75119a to your computer and use it in GitHub Desktop.
Set Theme Related To System
const setThemeRelatedToSystem = () => {
const getSystemtheme = () => {
// ... rest of the function code
}
const setTheme = (theme) => {
// ... rest of the funciton code
}
const watchSystemTheme = (cb) => {
// ... rest of the function code
}
// For the initial state
const systemTheme = getSystemTheme();
setTheme(systemTheme);
// Then start to watch for changes
watchSystemTheme((theme) => { //
setTheme(theme) // or watchTheme(systemTheme) if u know e6 and above
}) //
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment