File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const MainChart = () => {
77 const chartRef = useRef ( null )
88
99 useEffect ( ( ) => {
10- document . documentElement . addEventListener ( 'ColorSchemeChange' , ( ) => {
10+ const handleColorSchemeChange = ( ) => {
1111 if ( chartRef . current ) {
1212 setTimeout ( ( ) => {
1313 chartRef . current . options . scales . x . grid . borderColor = getStyle (
@@ -23,7 +23,10 @@ const MainChart = () => {
2323 chartRef . current . update ( )
2424 } )
2525 }
26- } )
26+ }
27+
28+ document . documentElement . addEventListener ( 'ColorSchemeChange' , handleColorSchemeChange )
29+ return ( ) => document . documentElement . removeEventListener ( 'ColorSchemeChange' , handleColorSchemeChange )
2730 } , [ chartRef ] )
2831
2932 const random = ( ) => Math . round ( Math . random ( ) * 100 )
You can’t perform that action at this time.
0 commit comments