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

147
Vistas
Bidirectional binding from Dropdown to date

On selection of date in the drop down I'm trying to auto-select calendar date, however corresponding auto-selection into date, works only for first selection into dropdown, not on subsequent changes.

Could you advise on why and relevant concept I need to refer back?

enter image description here

const [formValue, setFormValues] =
useState({

  date: null
});

const stringToDate = (data: any) => {
  const date = data.value === "6 Months"
    ? moment().subtract(6, "months")
    : data.value === "Last Month"
      ? moment().subtract(1, "months")
      : moment().subtract(1, "weeks");
  return date.toDate();
}

<GridColumn width={8} className="fullWidth">
          <label>How much back </label>
          <Dropdown
            fluid
            selection
            options={dropdownOptions}
            value={dateDropdownValue}
            onChange={(_e: any, data: any) => {
              setFormValues({
                ...formValue,
                date: stringToDate(data.value),
              });

              setDateDropdownValue(data.value);
            }}
          />
        </GridColumn>
        <GridColumn width={8} className="fullWidth">
          <label>Exact Date is:</label>
          <CalendarWrap>
            <DatePicker
              onChange={(date) => {
                setFormValues({
                  ...formValue,
                  date: date,
                });
              }}                  
              selected={formValue.date}
            />
            <CalendarImg src={Icons.CalendarImage}></CalendarImg>
          </CalendarWrap>
        </GridColumn>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As per my understanding, you should keep track of your dropdown's state in dependency array or useEffect, and once the value changes, call a function to reflect the desired date in Datepicker. I need more information to understand the whole problem

about 4 years ago · Juan Pablo Isaza Denunciar
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