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

212
Vistas
How to wrap MUI data grid rows and columns in useRef (to fix infinite loop in onSortModelChange)

I have the same problem as the question below. A comment said to use useRef to wrap rows and columns and use its .current value. How do I do that??

Material-UI Data Grid onSortModelChange Causing an Infinite Loop

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I could not figure out the useRef, and seeing this post is a month old you have most likely solved it by now. But for others like myself googling for a solution, here is how I solved the problem:

    const [sortModel, setSortModel] = useState<GridSortModel>([
    {
        field: 'created',
        sort: 'desc',
    },
]);

const handleSortChange = (model: GridSortModel) => {
    /* if statement to prevent the infinite loop by confirming model is 
     different than the current sortModel state */
    if (JSON.stringify(model) !== JSON.stringify(sortModel)) {
        setSortModel(model);
    }
};

<DataGrid
rows={taskData}
columns={myWorkColumns}
sortModel={sortModel}
onSortModelChange={(model) => handleSortChange(model)}
/>
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