Last active
August 31, 2018 08:23
-
-
Save rohozhnikoff/abd107912fa57595e2f108c87f8a988f to your computer and use it in GitHub Desktop.
[react-native] wrapped AsyncStorage with JSON support
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'; | |
const JSONAsyncStorage = Object.assign({}, AsyncStorage, { | |
getItem() { | |
return AsyncStorage.getItem.apply(null, arguments).then((res) => JSON.parse(res)); | |
}, | |
setItem(key, value) { | |
return AsyncStorage.setItem(key, JSON.stringify(value)) | |
} | |
}); | |
export default JSONAsyncStorage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment