title: My event not working eachtime I launch an event
body: <p>am new in react and a have this problem, that my <code>event</code> is most of the time getting <code>undefined</code> and I don't understand whats wrong with it, here is my code :</p>
  <pre><code>class DayPicker extends Component {
    constructor(props) {
      super(props)
      this.state = {
        sortedDays: {},
        index: this.props.index,
        buttonList: [],
        list: [],
      }
    }
  
    componentDidUpdate(prevProps, prevState) {
      if (prevState.buttonList === this.state.buttonList)
        this.setState({index: this.props.index})
    }
  
  
    setButtonList = () =&gt; {
      let buttonList = []
      let button = {}
      let index = 0
      let sortedDays = this.props.sortedDays
  
      for (let day in sortedDays) {
        button = (
          &lt;Button value={index} onClick={this.props.onIndexChange}&gt;
            {dayjs(day).format(&quot;D MMM&quot;)}
          &lt;/Button&gt;
        )
        buttonList.push(button)
        index++
      }
      return buttonList
    }
  
    render() {
      const { buttonList, list } = this.state
  
      return (
        &lt;div&gt;
          &lt;ButtonGroup&gt;{buttonList}&lt;/ButtonGroup&gt;
          &lt;table&gt;{list}&lt;/table&gt;
        &lt;/div&gt;
      )
    }
  }
  
  class AgendaSection extends Component {
    constructor(props) {
      super(props)
  
      this.state = {
        sortedDays: [],
        sessions: props.sessions,
        index: 0,
      }
    }
  
    onChange = event =&gt; {
      this.setState({ index: event.target.value })
    }
  
    render() {
      const { sortedDays, index } = this.state
      return (
        &lt;div&gt;
          &lt;DayPicker
            sortedDays={sortedDays}
            index={index}
            onIndexChange={this.onChange}
          /&gt;
        &lt;/div&gt;
      )
    }
  }
  </code></pre>
  <p>So i'm using 2 class <code>DayPicker</code> and <code>AgendaSection</code>, <code>DayPicker</code> is getting the onChange function from props giving by <code>AgendaSection</code> I don't understand what i've done wrong to make my event work &quot;sometimes&quot;
  Any issues on this problem ?</p>