Skip to content

Instantly share code, notes, and snippets.

@johnthepink
Created April 18, 2016 04:32
Show Gist options
  • Save johnthepink/6370f96b0894fe40c35ccfcfc61974be to your computer and use it in GitHub Desktop.
Save johnthepink/6370f96b0894fe40c35ccfcfc61974be to your computer and use it in GitHub Desktop.
async loadFromStorage() {
try {
const value = await AsyncStorage.getItem(STORAGE_KEY);
if (value !== null) {
this.setState({
api_key: value
});
}
} catch (error) {
console.log(`AsyncStorage error: ${error.mesage}`);
}
}
async writeToStorage() {
this.setState({
api_key: this.state.input_value
});
this.fetchData();
try {
await AsyncStorage.setItem(STORAGE_KEY, this.state.input_value);
} catch (error) {
console.log(`AsyncStorage error: ${error.message}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment