title: Storing an object in state after function
body: <p>I apologize in advance for my bad language. Reading the question will take you no more than 30 seconds.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>
      constructor(props) {
          super(props);
          this.state = {
              report: [],
              reports: [],
              donaters: [],
              donate_report: [],
              donaters_count: [],
              donaters_recurrent_count: [],
              dates: [],
              menu: [
                  {
                      key: 2018,
                      title: "2019",
                      opened: true,
                      info: [
                          {
                              key: 11,
                              title: 'dec',
                              opened: false,
                              content: []
                          }, {
                              key: 10,
                              title: 'nov',
                              opened: false,
                              content: []
                          }, {
                              key: 9,
                              title: 'oct',
                              opened: false,
                              content: []
                          }]
                  },
                  {
                      key: 2019,
                      title: "2018",
                      opened: false,
                      info: [
                          {
                              key: 1,
                              title: 'jan',
                              opened: false,
                              content: []
                          }]
                  }],
              active_menu: 2018,
              active_month: [],
              active_info: [],
          }
      }
  
      componentDidMount(value) {
          const {active_menu} = this.state;
          fetch(`${api.root}/donate_report?year=${active_menu}`, {param: value})
              .then((response) =&gt; response.json())
              .then((donate_report) =&gt; {
                  this.setState({
                      report: donate_report.report[0].reports,
                      donaters: donate_report.report[0].donaters,
                      active_info: active_menu.info
                  })
              })
      }
  
  
      toggleInfo(index) {
          const info = this.state.active_info.slice();
          info[index].opened = !info[index].opened;
          this.setState({
              active_info: info,
              active_month: info[index].key,
              dates: this.state.donaters[info[index].key][info[index].key + 1][0]
          })
      }
  
      toggleMenu(menu, value) {
          if (this.state.active_menu !== menu) {
              this.setState({active_menu: menu, mobile_menu_opened: false, menu_changed: true});
          fetch(`${api.root}/donate_report?year=${this.state.active_menu}`, {param: value})
                  .then((response) =&gt; response.json())
                  .then((donate_report) =&gt; {
                      this.setState({
                          report: donate_report.report[0].reports,
                          donaters: donate_report.report[0].donaters,
                          dates: donate_report.report[0].donaters[this.state.active_month][this.state.active_month + 1][0],
                          active_info: this.state.menu.info
                      });
                      console.log('update');
                  });
          }
      }
  </code></pre>
  
  <p>Tell me, please, how can I store <code>info</code> from <code>menu</code> in <code>active_month</code> provided that <code>menu.key</code> is equal to <code>active_menu</code></p>
  
  <p>I have no problem assigning the selected menu to the state <code>active_menu</code> with my function <code>toggleMenu()</code> :</p>
  
  <pre><code>if (this.state.active_menu !== menu) {
              this.setState({active_menu: menu})
  }
  </code></pre>
  
  <p>Sorry, if I wrote inaccurately, I will try to write in detail:</p>
  
  <p>If the user chooses the year 2019, <code>active_menu</code> gets the key from the <code>menu</code> (For 2019 it is <code>2019</code> :)) And in the <code>active_month</code>, gets the whole <code>info</code> which in our case will be</p>
  
  <pre><code>{
  key: 1,
  title: 'jan',
  opened: false,
  content: []
  }
  </code></pre>
  
  <p>Thanks for any of your answer and advice!</p>