Skip to content

Instantly share code, notes, and snippets.

@cyb3rsalih
Created April 20, 2020 12:50
Show Gist options
  • Select an option

  • Save cyb3rsalih/53c00549cba304b50e9879df07bf02e9 to your computer and use it in GitHub Desktop.

Select an option

Save cyb3rsalih/53c00549cba304b50e9879df07bf02e9 to your computer and use it in GitHub Desktop.
React Native Async Storage | Uygulamada birşeyler yaptım, uygulamaya geri döndüm. Kaldığım yerden devam etsin....
_storeData = async (last) => {
console.log("store data:"+last)
AsyncStorage.setItem("LAST",last,(err) =>
{
if(err == null ){
console.log("Set edildi: "+last)
}else{
console.log("Error:"+err)
}
}
)
}
_retrieveData = async () => {
AsyncStorage.getItem("LAST",(err,result) => {
if(result == null){
// RESULT IS NOT THE VALUE SAVED!!!!!
// IT IS JUST FOR CHECK THERE IS VALUE
console.log("İlk kez geliyorsun.")
this._storeData('0')
}else{
console.log("Daha önce gelmişsin...")
}
}).then((value) => {
console.log("RESULT: "+value)
value = Number.parseInt(value);
this.setState({currentState:value},() => {
console.log("Updated your currentState.")
})
} )
};
componentDidMount(){
this._retrieveData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment