How to add new data to the state ? Here is the code:
import React, { Component } from 'react'; class MetricaGoals extends Component { constructor() { super(); this.state = { metricaGoalsList : [] metricaGoalsData : [] } } componentDidMount() { const OATH_TOKEN = 'token'; const PROJECT_ID = '23077159'; fetch(`https://api-metrika.yandex.ru/management/v1/counter/23077159/goals ?oauth_token=${OATH_TOKEN}`) .then(response => response.json()) .then(data => { const DATA = data.goals this.setState({ metricaGoalsList: DATA }) }); let acc = []; for (var i = 0; i < this.state.metricaGoals.metricaGoalsList.length; i++) { fetch(`https://api-metrika.yandex.ru/stat/v1/data/bytime ?date1=2018-06-13 &date2=2018-07-13 &group=day &metrics=ym:s:goal${this.state.metricaGoals.metricaGoalsList.id}conversionRate, ym:s:goal${this.state.metricaGoals.metricaGoalsList.id}reaches &id=${PROJECT_ID} &oauth_token=${OATH_TOKEN}`) .then(response => response.json()) .then(data => { acc.push(data.data[0].metrics) this.setState({ metricaGoalsData: acc }) }) } } render() { return ( <div className="MetricaGoals"> <ul className="goals__list"> { this.state.metricaGoals.metricaGoalsList.map(i => { return ( <li key={i.id} className="goals__item"> {this.state.metricaGoalsData[0]} </li> ) }) } </ul> </div> ); } } export default MetricaGoals; Nothing is written to the array? Why? How to make it recorded?