Created
May 21, 2020 22:37
-
-
Save shinchit/868d4d92f2ac1f25d70a2d9ea427a6bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react'; | |
import { Text } from 'react-native'; | |
import { Appearance, useColorScheme } from 'react-native-appearance'; | |
Appearance.getColorScheme(); | |
const SomeComponent = (props) => { | |
const [colorScheme, setColorScheme] = useState('light'); | |
const cs = useColorScheme(); | |
useEffect(() => { | |
setColorScheme(cs); | |
}, [cs]); | |
const isDarkModeEnabled = () => { | |
return colorScheme === 'dark'; | |
} | |
return ( | |
<Text>{isDarkModeEnabled}</Text> | |
); | |
}; | |
export default SomeComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment