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

203
Vistas
how to stop state change to render material-ui table in reactjs

the next part of codes are inside my app.js: I got this state:

const [open,setOpen] = useState(false)

which is used to determine if a material-ui Alert should appear on the screen for 3 second with this code:

useEffect(()=>{
     setTimeout(()=> {
        setOpen(false)
     },3000)
},[open])

and returned as:

<Collapse in ={open}>
  <Alert severity={severity}>
    {alertMessage}
  </Alert>
</Collapse>

setOpen sent to the component Table as prop

<Table
loading={loading}
data={data}
setAlertState={setOpen}
/>

the next parts are in Table.js: in table.js I am working with:

import{
 useGridApiRef,
 DataGridPro,
 GridOverlay,
 GridActionsCellItem,
 useGridState
} from '@mui/x-data-grid-pro';

when I click to edit the row and then save this function run(this is not the full function ofc):

const handleSaveclick = (id) =>async(event)=>{
   if(validate_edit())
   {
      apiRef.current.updateRow([{...row}]);
      handleAlert("success","Word edited!");
   } 

handleAlert:

const handleAlert = (severity,alertMessage)=>
{
   setSeverity(()=>severity);
   setAlertMessage(()=>alertMessage);
   setAlertState(()=>true);
}

well the problem is that my data grid table updates himself, but when the alert goes true/false the table returns to what was before.

how to handle this render? what I do wrong? thanks in advance.

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

0

Without a full example, it will be hard to solve.

Most of the time such bugs appear when you rerender the DataGrid. You have two solutions:

  • avoid rerendering. Can not be more precise without example
  • control the data you want to keep them up to date
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