Created
May 23, 2021 21:21
-
-
Save Yoncity/d828386833766788d226d886ea0bc9b9 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 {useContext} from 'react'; | |
import {ThemeContext} from '../components/ThemeManager'; | |
import * as AsyncStorage from '../components/AsyncStorage'; | |
export default props => { | |
const {theme, toggleTheme} = useContext(ThemeContext); | |
const readTheme = async () => { | |
const data = await AsyncStorage.retrieveData('SETTINGS_KEY'); | |
if (data !== null && data !== undefined) { | |
toggleTheme(data); | |
} | |
}; | |
const updateTheme = async value => { | |
await AsyncStorage.storeData('SETTINGS_KEY', value); | |
toggleTheme(value); | |
}; | |
return [theme, readTheme, updateTheme]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment