Skip to content

Commit

Permalink
removed unncecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Saurabh-Rana17 committed Oct 10, 2024
1 parent 8156b16 commit 3d8d71b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Context/themeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ const getInitialTheme = () => {
export function ThemeProvider({ children }) {
const [theme, setTheme] = useState(getInitialTheme());

// Handling theme change
// Handle theme change
const changeTheme = () => {
const newTheme = theme.mode === "light" ? dark : light;
setTheme(newTheme);
};

// Updating localStorage whenever the theme changes
useEffect(() => {
localStorage.setItem("theme", JSON.stringify(theme));
}, [theme]);

// Memoizing the context value to avoid unnecessary re-renders
const contextValue = useMemo(() => ({ theme, changeTheme }), [theme]);

return (
Expand Down

0 comments on commit 3d8d71b

Please sign in to comment.