Skip to content

Instantly share code, notes, and snippets.

@rohozhnikoff
Last active August 31, 2018 08:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rohozhnikoff/abd107912fa57595e2f108c87f8a988f to your computer and use it in GitHub Desktop.
Save rohozhnikoff/abd107912fa57595e2f108c87f8a988f to your computer and use it in GitHub Desktop.
[react-native] wrapped AsyncStorage with JSON support
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