Asked
Active
Viewed 117 times
-3
-
https://stackoverflow.com/questions/31045716/react-this-setstate-is-not-a-function is the the problem you are getting ? – strek Dec 16 '19 at 03:30
1 Answers
0
This is a Scope problem, replace your function callback by an arrow function like this:
apiServer.getBalance(myData.token, myData.id, response => {
if (response.success) {
console.log("Balance success");
balance = response.success.balance;
this.setState({ balance: response.success.balance });
} else {
//login failed
console.log("failed");
}
});
Happy coding.

jbergeron
- 515
- 3
- 8