I am new to React Native and ES6. I can access outer scope 'this' in this code:
my_function()
{
this.setState = {};//outer scope this
return fetch('https://facebook.github.io/react-native/movies.json')
.then((response) => {
console.log(this); //this shows the correct outer scope this
return response.json()})
.then(...);
}
But if I write this arrow function out as:
return fetch('https://facebook.github.io/react-native/movies.json')
.then(function(response){
console.log(this); //this becomes some 'DedicatedWorkerGlobalScope' when I am debugging?
return response.json();
}).then(...)
I don't understand why this two function is not equivalent?