summaryrefslogtreecommitdiff
path: root/hooks/useColorScheme.web.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-07-15 17:20:58 +0700
committerpolwex <polwex@sortug.com>2025-07-15 17:20:58 +0700
commita528bd94a6e8e25010ae26a305550b211df0ddc6 (patch)
tree887425ddc3160ae023292dfefc49d77c2eb8dcec /hooks/useColorScheme.web.ts
Initial commit
Generated by create-expo 3.4.3.
Diffstat (limited to 'hooks/useColorScheme.web.ts')
-rw-r--r--hooks/useColorScheme.web.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/hooks/useColorScheme.web.ts b/hooks/useColorScheme.web.ts
new file mode 100644
index 0000000..7eb1c1b
--- /dev/null
+++ b/hooks/useColorScheme.web.ts
@@ -0,0 +1,21 @@
+import { useEffect, useState } from 'react';
+import { useColorScheme as useRNColorScheme } from 'react-native';
+
+/**
+ * To support static rendering, this value needs to be re-calculated on the client side for web
+ */
+export function useColorScheme() {
+ const [hasHydrated, setHasHydrated] = useState(false);
+
+ useEffect(() => {
+ setHasHydrated(true);
+ }, []);
+
+ const colorScheme = useRNColorScheme();
+
+ if (hasHydrated) {
+ return colorScheme;
+ }
+
+ return 'light';
+}