Home > Enterprise >  useStates are not updating in React JS
useStates are not updating in React JS

Time:02-01

The values of the useState are not getting updated, please provide me a solution for this.

Even though I use UpdateRUInfo(recorderinfo),Updatemi5(mi5module),Updateb5(ebmcard),Updateeth(ethsrc) at the end, the values are not getting reflected.

So how could this be resolved for the values to get updated. Is there any problem with the structure of the code.

CodePudding user response:

React uses object references to determine if state has been updated. Since you are not creating new objects, but mutating them and keeping the same references, React will not update.

Instead do something like:

Updatemi5([{...mi5module, data: whatever}]);

CodePudding user response:

You Cannot set the state value, the way you are setting

you can use the following way.

updateRUInfo([{...recorderinfo, totaldatarate:dateRate}])
  •  Tags:  
  • Related