Skip to content

Commit

Permalink
chore: useEffect in ChangeStyleTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
langz committed Oct 24, 2023
1 parent f14ecd4 commit 25df6fd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/dnb-design-system-portal/src/core/ChangeStyleTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import {

export default function ChangeStyleTheme({ label = null } = {}) {
const themes = getThemes()
const { name } = getTheme()
const { update } = React.useContext(Context)

const [themeName, setThemeName] = React.useState(null)

React.useEffect(() => {
const { name } = getTheme()
setThemeName(name)
}, [])

const date = Object.entries(themes).reduce((acc, [key, value]) => {
if (!value?.hide) {
acc[key] = capitalizeFirstLetter(value.name)
Expand All @@ -22,7 +28,7 @@ export default function ChangeStyleTheme({ label = null } = {}) {
return (
<Dropdown
id="change-theme"
value={name}
value={themeName}
data={date}
label={label}
on_change={({ data: { value } }) => {
Expand Down

0 comments on commit 25df6fd

Please sign in to comment.