webyonet / react-native-android-location-services-dialog-box

React Native Android Location Services Dialog Box
MIT License
182 stars 50 forks source link

Calling a method #63

Closed Pushpi1992 closed 6 years ago

Pushpi1992 commented 6 years ago

If i call another method inside a .then(success) then state is not changing because that method is not calling. Please tell me how to call any method from inside .then(success)

webyonet commented 6 years ago
.then(function(success) {
    this.setState({ ... }); // call self method
}.bind(this) //  <== this

or

async checkIsLocation() {
        let check = await LocationServicesDialogBox.checkLocationServicesIsEnabled({
            message: "Use Location ?",
            ok: "YES",
            cancel: "NO",
        }).catch(error => error);

        this.setState({ ... });  // call self method
}