Created
April 20, 2020 12:50
-
-
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....
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
| _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