Skip to content

Commit af5074a

Browse files
committed
return light mode in case no mode available
1 parent cbdbf26 commit af5074a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/ThemeProvider.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ export const StorybookThemeProvider = (props: {
8383
};
8484

8585
export const getThemeValue = (key: keyof Palette) => {
86-
const theme = React.useContext(ThemeContext) ?? defaultTheme;
87-
const darkMode = useDarkMode(false);
88-
return darkMode.value ? theme.dark![key] : theme.light![key];
86+
try {
87+
const theme = React.useContext(ThemeContext) ?? defaultTheme;
88+
const darkMode = useDarkMode(false);
89+
return darkMode.value ? theme.dark![key] : theme.light![key];
90+
} catch {
91+
defaultTheme.light![key];
92+
// in case of error, return the default value
93+
}
8994
};

0 commit comments

Comments
 (0)