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

179
Vistas
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 Respuestas
Responde la pregunta

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 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