Created
June 22, 2020 15:43
-
-
Save LucasFsc/d4ad0facec8af12c31fecd3ca74d30f6 to your computer and use it in GitHub Desktop.
A simple function for RN to help with AsyncStorage
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 AsyncStorage from '@react-native-community/async-storage' | |
export default key => ({ | |
set: payload => AsyncStorage.setItem(key, JSON.stringify(payload)), | |
get: async () => { | |
const _ = AsyncStorage.getItem(key) | |
return _ ? JSON.parse(_) : null | |
}, | |
remove: () => AsyncStorage.removeItem(key) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment