Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda