When using ES6 classes of RN watch binding this- thiscan not, as you might think, if you do not have bound her.
onPress = { this._onPressGet.bind(this) }
or in the constructor
constructor(props) {
super(props);
this.state = {
initialPosition: 'unknown',
lastPosition: 'unknown'
};
this._onPressGet = this._onPressGet.bind(this);
}
or maybe the most elegant way
_onPressGet = () => {
// Function body
}
In order of least preferred.
source
share