Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!