Skip to content

Commit

Permalink
update theme provider
Browse files Browse the repository at this point in the history
  • Loading branch information
isthaison committed Dec 4, 2024
1 parent 7fbf5ad commit b91187e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions web/src/components/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createContext, useContext, useEffect, useState } from 'react';
import React, { createContext, useContext, useEffect, useState } from 'react';

type Theme = 'dark' | 'light' | 'system';

Expand Down Expand Up @@ -44,20 +44,18 @@ export function ThemeProvider({
root.classList.add(systemTheme);
return;
}

localStorage.setItem(storageKey, theme);
root.classList.add(theme);
}, [theme]);

const value = {
theme,
setTheme: (theme: Theme) => {
localStorage.setItem(storageKey, theme);
setTheme(theme);
},
};
}, [storageKey, theme]);

return (
<ThemeProviderContext.Provider {...props} value={value}>
<ThemeProviderContext.Provider
{...props}
value={{
theme,
setTheme,
}}
>
{children}
</ThemeProviderContext.Provider>
);
Expand Down

0 comments on commit b91187e

Please sign in to comment.