Я пытаюсь вызвать функцию setState внутри цикла _.map, но цикл потерял свойство «this», и я не могу использовать setState для этого, потому что это = не определеноИспользовать свойство «this» внутри _.map
cargaDinamica(){
_.map(this.state.redis, function(cache){
obj.url = 'http://localhost:7000/viewlogredis';
ServiceOS(obj)
.then(retorno => {
console.log("aaaa", this);
view = retorno;
this.setState({log : view});
})
.catch(err => {throw new Error(err)});
obj = {url : 'http://localhost:7000' + cache.WebService,
IPRedis: cache.IPDBMaster,
WebService: cache.WebService,
log : log};
console.log("CARGA: ", obj);
ServiceOS(obj)
.then(function(carga) {
console.log('CHEGOU AQUI');
console.log("OK");
})
.catch(err => {throw new Error(err)});
});
},
это моя реагировать функция/\
передать функцию() {}. Bind (this) с ограниченным контекстом –