File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 11import React from "react" ;
2- import { useMemo , useLayoutEffect , useState } from "react" ;
2+ import { useMemo , useLayoutEffect , useState , useCallback } from "react" ;
33import { useLocation } from "react-router-dom" ;
44import logoWide from "src/assets/svg/logo-wide.svg" ;
55import logoSquare from "src/assets/svg/logo-square.svg" ;
@@ -55,12 +55,12 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
5555 }
5656 } , [ ] ) ;
5757
58- function toggleTheme ( ) {
58+ const toggleTheme = useCallback ( ( ) => {
5959 const newTheme = isDark ? "light" : "dark" ;
6060 setIsDark ( ! isDark ) ;
6161 localStorage . setItem ( "theme" , newTheme ) ;
6262 document . documentElement . setAttribute ( "data-theme" , newTheme ) ;
63- }
63+ } , [ isDark ] ) ;
6464
6565 return (
6666 < div className = "bg-neutral" >
@@ -134,7 +134,9 @@ export function TopBar({ version, links }: TopBarProps): JSX.Element {
134134 < path d = "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" > </ path >
135135 </ svg >
136136 < input
137- onClick = { toggleTheme }
137+ onClick = { ( ) => {
138+ toggleTheme ( ) ;
139+ } }
138140 id = "theme-toggle"
139141 type = "checkbox"
140142 value = "dzcodeLight"
You can’t perform that action at this time.
0 commit comments