feat: customize theme and locale based on query params

This commit is contained in:
akashrajpurohit_postman 2022-08-21 17:00:40 +05:30
parent 0f976be5d8
commit ec7bc92497
2 changed files with 18 additions and 0 deletions

View file

@ -23,5 +23,14 @@ export default function useTheme() {
document.body.setAttribute('data-theme', theme);
}, [theme]);
useEffect(() => {
const url = new URL(window.location.href);
const theme = url.searchParams.get('theme');
if (['light', 'dark'].includes(theme)) {
saveTheme(theme);
}
}, []);
return [theme, saveTheme];
}