Skip to content

Commit a80bba6

Browse files
committed
fix: followSystem not work when system color scheme change
1 parent 7c32be7 commit a80bba6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/providers/theme-provider.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC, PropsWithChildren } from "react";
2-
import { useCallback } from "react";
2+
import { useCallback, useEffect } from "react";
33
import { useColorScheme } from "react-native";
44

55
import { useFonts } from "expo-font";
@@ -56,6 +56,12 @@ export const ThemeProvider: FC<PropsWithChildren<{}>> = ({ children }) => {
5656

5757
const isDarkMode = mode === "dark";
5858

59+
useEffect(() => {
60+
if (followSystem) {
61+
setMode(colorScheme);
62+
}
63+
}, [followSystem, colorScheme, setMode]);
64+
5965
return (
6066
<ThemeContext.Provider value={{
6167
mode,

0 commit comments

Comments
 (0)