diff --git a/src/ThemeContext.js b/src/ThemeContext.js index e5d1e8d..a354e57 100644 --- a/src/ThemeContext.js +++ b/src/ThemeContext.js @@ -8,8 +8,13 @@ export function ThemeProvider({ children }) { // document.body.className = theme; ); + const updateTheme = newTheme => { + setTheme(newTheme); + localStorage.setItem('theme', newTheme); + }; + return ( - + {children} ); diff --git a/src/UI/Navigation.js b/src/UI/Navigation.js index e1fc101..b13a943 100644 --- a/src/UI/Navigation.js +++ b/src/UI/Navigation.js @@ -9,10 +9,10 @@ let section = window.location.pathname.split('/')[2]; let chapter = window.location.pathname.split('/')[3]; const Navigation = () => { - const { theme, setTheme } = useTheme(); + const { theme, updateTheme } = useTheme(); const toggleTheme = () => { - setTheme((theme === 'light') ? 'dark' : 'light'); + updateTheme((theme === 'light') ? 'dark' : 'light'); } return (