Created
April 18, 2016 04:32
-
-
Save johnthepink/6370f96b0894fe40c35ccfcfc61974be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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