Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
My event not working eachtime I launch an event

am new in react and a have this problem, that my event is most of the time getting undefined and I don't understand whats wrong with it, here is my 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 = () => {
    let buttonList = []
    let button = {}
    let index = 0
    let sortedDays = this.props.sortedDays

    for (let day in sortedDays) {
      button = (
        <Button value={index} onClick={this.props.onIndexChange}>
          {dayjs(day).format("D MMM")}
        </Button>
      )
      buttonList.push(button)
      index++
    }
    return buttonList
  }

  render() {
    const { buttonList, list } = this.state

    return (
      <div>
        <ButtonGroup>{buttonList}</ButtonGroup>
        <table>{list}</table>
      </div>
    )
  }
}

class AgendaSection extends Component {
  constructor(props) {
    super(props)

    this.state = {
      sortedDays: [],
      sessions: props.sessions,
      index: 0,
    }
  }

  onChange = event => {
    this.setState({ index: event.target.value })
  }

  render() {
    const { sortedDays, index } = this.state
    return (
      <div>
        <DayPicker
          sortedDays={sortedDays}
          index={index}
          onIndexChange={this.onChange}
        />
      </div>
    )
  }
}

So i'm using 2 class DayPicker and AgendaSection, DayPicker is getting the onChange function from props giving by AgendaSection I don't understand what i've done wrong to make my event work "sometimes" Any issues on this problem ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!