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

178
Visualizações
MUI DatePicker hangs on big date changes

MUI DatePicker (either from Labs or X) was working fine. I cannot work out what happened, but it now hangs if I want to change the date by ten years. It seems like the code goes into an infinite loop, but there's no output to the console. The code is

function DateSelector(props) {
  const setValue = value => {
    if (value !== null) {
      const checked = checkDate(value);
      props.handler(checked);
    }
  }
  return (
    <DatePicker
      label={props.label}
      inputFormat="d/M/y"
      mask=""
      value={props.date}
      onChange={(value) => {
        setValue(value);
      }}
      renderInput={(params) => (
        <Tooltip title={"select " + props.label + " date"} arrow>
          <TextField size="small" {...params} />
        </Tooltip>
      )}
    />
  );
}

props.date is an App-level state that is handed down to the picker component. checkDate is a simple function to ensure the date is in the correct range (I've bug-tested it, and it's not the cause of the problem as far as I can see). props.handler changes the App-level state. I wonder if the problem is that I'm manipulating state at the App-level directly through the picker.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is now resolved!

The problem here is that props.date is a date object stored as an App state that is passed to the component. The component is modifying this directly! Instead it should work with a deep copy of the date object.

Instead of

value={props.date}

it should have

value={new Date(props.date.getTime())}
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