Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda