'un o işlevinden setState ayarlanamadı durumu, fetch
işlevini kullanarak aldığım promise
durumundan güncelleştirmeye çalışıyorum.Promise
componentDidMount(){
fetch(url).then((responseText) => {
var response = responseText.json();
response.then(function(response){
this.setState(response);
});
});
}
Ben setState
Sonra bir işlev
olmadığı hatayı başlamıştı, ben aşağıda gibi this
değer geçmek bind(this)
çalıştı.
componentDidMount(){
fetch(url).then((responseText) => {
var response = responseText.json();
response.then(function(response){
this.setState(response);
});
}).bind(this);
}
Artık çalışmıyor. Yine aynı hata.
Bu yöntemi okunabilir durumda buluyorum. – ApertureSecurity