Skip to content

Instantly share code, notes, and snippets.

@tonyvu2014
Last active June 10, 2018 07:48
Show Gist options
  • Save tonyvu2014/7d25911d72efa945f6e2a6f295e77674 to your computer and use it in GitHub Desktop.
Save tonyvu2014/7d25911d72efa945f6e2a6f295e77674 to your computer and use it in GitHub Desktop.
AsyncStorage
AsyncStorage.getItem('preferences')
.then(value => {
if (value) {
console.log('PreferencesScreen - preferences:', value)
let terms = []
let prefs = value.split(',')
for (let i = 0; i < prefs.length; i++) {
terms.push({key: i, term: prefs[i]})
}
this.setState({terms: terms})
} else {
this.setState({terms: []})
}
}).done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment