I have a component in react native:
export default class Screen extends Component {
constructor(props){
super(props);
this.state = {
prop1: false,
prop2: simpleFunc
};
}
simpleFunc = () => { /*...*/ }
componentWillMount() {
BackgroundGeolocation.on('location', this.onLocation);
The last line is callback method that will be called on new location.
From that method I can't access this.state
or this.simpleFunc()
.
What should I do in order to update state from callback function?