Skip to content

Commit 944395e

Browse files
authored
Merge pull request #287 from hyoban/main
fix: followSystem not work when system color scheme change
2 parents 7c32be7 + c17ece8 commit 944395e

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

.changeset/polite-boats-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"xlog": patch
3+
---
4+
5+
fix followSystem option not work

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)