Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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