Skip to content

Commit

Permalink
feat: use useEffect to set theme
Browse files Browse the repository at this point in the history
  • Loading branch information
lpohren committed Oct 13, 2020
1 parent 1abd874 commit 1fcae84
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/ThemeSwitch/ThemeSwitch.js
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';

import { Option } from '@ui5/webcomponents-react/lib/Option';
Expand All @@ -21,7 +21,9 @@ const style = {

const ThemeSwitch = ({ dialogRef, storedTheme = localStorage.getItem('reactSeedSelectedTheme') }) => {
const { t } = useTranslation();
setTheme(storedTheme ? storedTheme : 'sap_fiori_3');
useEffect(() => {
setTheme(storedTheme ? storedTheme : 'sap_fiori_3');
});
const onChange = (event) => {
storedTheme = event.detail.selectedOption.dataset.value;
localStorage.setItem('reactSeedSelectedTheme', storedTheme);
Expand Down

0 comments on commit 1fcae84

Please sign in to comment.