What is the easiest way to detect the state change of a complex object in Reactjs

859 views Asked by At

I have a complex object as follows

const myObject = { 
                 title:"main title",
                 row:[
                       {rowTitle:"t1",index:1},
                       {rowTitle:"t2",index:2}
                 ],
                 column:[
                          {columnTitle:"c1",index:1},
                          {columnTitle:"c2",index:2},
                 ]
}

I need to detect if the properties change or not.

isObjectUpdated(myObject){
  // return true/false
}
1

There are 1 answers

0
Bruno Gava Guerra On BEST ANSWER

In the case that you want the component / screen to be remounted if this object changes, you can use the useState() hook to achieve this behavior.