We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cbdbf26 commit af5074aCopy full SHA for af5074a
src/components/ThemeProvider.tsx
@@ -83,7 +83,12 @@ export const StorybookThemeProvider = (props: {
83
};
84
85
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];
+ try {
+ const theme = React.useContext(ThemeContext) ?? defaultTheme;
+ 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
+ }
94
0 commit comments