Created
December 31, 2018 13:20
-
-
Save tapir/c0b0f75d771f77a3d5b0512f67eb5835 to your computer and use it in GitHub Desktop.
test.js
This file contains 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
export default class HomeScreen extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {token: ''}; | |
this.getToken = this.getToken.bind(this); | |
getToken(); | |
} | |
getToken() { | |
AsyncStorage.getItem('JWT_TOKEN') | |
.then((token) => { | |
console.warn(token); // Success | |
this.setState({token: token}); | |
}) | |
.catch((error) => this.toast(error)); | |
} | |
componentDidMount() { | |
console.warn(this.state.token); // Fail | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment