title: How to call other constructors when re-rendering with setState in reactJS?
body: <p>I have these constructors in a component.
  Idea here is to have button with an onClick attribute and when the button is clicked the onItemClick() functions invokes which if the right button is clicked increments this.state.index by 1. </p>
  
  <p>The problem here is that the state changes but other constructors do not get called again so nothing changes in the component.</p>
  
  <p>Question is how do I call those constructors every time the state changes? Or how should I rewrite the code so the logic behind it stays, meaning that with every state change I get all the new information which depends on the state? </p>
  
  <pre><code>constructor() {
      super()
      this.state = {
        index: 1,
      }
      this.currentQ = data[this.state.index]
      this.answers = Object.values(this.currentQ.answers).map((item, index) =&gt; {
        return &lt;button onClick={() =&gt; this.onItemClick(index)}&gt;{item}&lt;/button&gt;
      })
    }
  </code></pre>
  
  <p>EDIT: providing the full code of component below. Thank you for the answers!</p>
  
  <pre><code>import React, { Component } from 'react';
  import {data} from './input.js';
  
  
  class Card extends Component {
    constructor() {
      super()
      this.state = {
        index: 1,
      }
      this.currentQ = data[this.state.index]
      this.answers = Object.values(this.currentQ.answers).map((item, index) =&gt; {
        return &lt;button onClick={() =&gt; this.onItemClick(index)}&gt;{item}&lt;/button&gt;
      })
    }
  
    onItemClick = (index) =&gt; {
      let rightAnswer = this.currentQ.rightAnswer
      let userGuess = Object.keys(this.currentQ.answers)[index]
  
      rightAnswer === userGuess ? this.setState({index: this.state.index += 1}) : console.log('false')
    }
  
    render() {
      return (
        &lt;div&gt;
          &lt;h2&gt;{this.currentQ.engWord}&lt;/h2&gt;
          {this.answers}
        &lt;/div&gt;
      )
    }
  }
  export default Card;
  </code></pre>