diff --git a/packages/documentation/src/components/ThemeBorders/index.tsx b/packages/documentation/src/components/ThemeBorders/index.tsx index 87f632bc55..1c85f33a2f 100644 --- a/packages/documentation/src/components/ThemeBorders/index.tsx +++ b/packages/documentation/src/components/ThemeBorders/index.tsx @@ -18,6 +18,7 @@ import { import React, { useState } from 'react'; import { themeBorders } from './borders'; import './ThemeBorders.css'; +import { useTheme } from '@site/src/utils/hooks/useTheme'; function Search(props: { onChange: (value: string) => void }) { return ( @@ -56,6 +57,7 @@ function BorderPreview(props: { border: string }) { const ThemeBorders: React.FC = () => { const [borders, setBorders] = useState(themeBorders); + useTheme(); const updateFilter = (filter) => { setBorders([ diff --git a/packages/documentation/src/components/ThemeColors/index.tsx b/packages/documentation/src/components/ThemeColors/index.tsx index f65012929d..9bac23ee6a 100644 --- a/packages/documentation/src/components/ThemeColors/index.tsx +++ b/packages/documentation/src/components/ThemeColors/index.tsx @@ -16,9 +16,10 @@ import { IxRow, showToast, } from '@siemens/ix-react'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useLayoutEffect, useState } from 'react'; import { resolveColorValue, themeColors } from './resolve-colors'; import './ThemeColors.css'; +import { useTheme } from '@site/src/utils/hooks/useTheme'; function Search(props: { onChange: (value: string) => void }) { return ( @@ -59,6 +60,7 @@ function ColorPreview(props: { color: string }) { const ThemeColors: React.FC = () => { const [colors, setColors] = useState(themeColors); + const theme = useTheme(); const updateFilter = (filter) => { setColors([ @@ -80,11 +82,9 @@ const ThemeColors: React.FC = () => { }); }; - useEffect(() => { - window.addEventListener('theme-change', () => { - setColors([...colors]); - }); - }, []); + useLayoutEffect(() => { + setColors([...colors]); + }, [theme]); return (