Skip to content

Commit 8a043be

Browse files
committed
log error instead of crashing when no theme context is available
1 parent 8ef83cc commit 8a043be

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/hooks/persisted/useTheme.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ export const ThemeProvider = ({ children }: PropsWithChildren) => {
159159
export const useTheme = (): ThemeColors => {
160160
const theme = useContext(ThemeContext);
161161
if (!theme) {
162-
throw new Error('useTheme must be used within a <ThemeProvider />');
162+
// eslint-disable-next-line no-console
163+
console.error('useTheme must be used within a <ThemeProvider />');
164+
return {} as ThemeColors;
163165
}
164166

165167
return theme;

src/theme/utils/setBarColor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export const setStatusBarColor = (color: ThemeColors | ColorInstance) => {
1616
};
1717

1818
export const changeNavigationBarColor = (color: string, isDark = false) => {
19-
NavigationBar.setBackgroundColorAsync(color);
19+
//NavigationBar.setBackgroundColorAsync(color);
2020
NavigationBar.setButtonStyleAsync(isDark ? 'light' : 'dark');
2121
};

0 commit comments

Comments
 (0)