Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix error set state in render

Ammar Ahmedb034a5942262
diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsx
index 091d618c7..4fa4e2d71 100644
--- a/apps/mobile/app/app.tsx
+++ b/apps/mobile/app/app.tsx
@@ -127,13 +127,15 @@ export const withTheme = (Element: (props: any) => JSX.Element) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- const nextTheme = colorScheme === "dark" ? darkTheme : lightTheme;
- if (JSON.stringify(nextTheme) !== JSON.stringify(currTheme)) {
- useThemeEngineStore
- .getState()
- .setTheme(colorScheme === "dark" ? darkTheme : lightTheme);
- currTheme = nextTheme;
- }
+ useEffect(() => {
+ const nextTheme = colorScheme === "dark" ? darkTheme : lightTheme;
+ if (JSON.stringify(nextTheme) !== JSON.stringify(currTheme)) {
+ useThemeEngineStore
+ .getState()
+ .setTheme(colorScheme === "dark" ? darkTheme : lightTheme);
+ currTheme = nextTheme;
+ }
+ }, [colorScheme, darkTheme, lightTheme]);
return (
<I18nProvider i18n={i18n}>