Scope binding for react app

Class level function binding

If you write you code this way, this -> is class scoped. If you have defined username / password in your state, then you will be able to access it.

<Button onPress={() => {
this.authenticate(this.state.username, this.state.password);

If you tend to write you code this way, it means a local binding function,

<Button onPress={this.authenticate} title="Login" />

async authenticate() {

username = this.state.username; //undefined
password = this.state.password; // undefined


Popular posts from this blog

Solving Sonarqube :- Project was never analyzed. A regular analysis is required before a branch analysis

spark - pyspark reading from excel files