For React to properly “understand” that you have updated data in a state variable, you need to use the “set state function” and NOT update the state variable directly.
In your code, put the data into a new and temporary variable, the after the
That puts the data in theTempVariable into the
orders variable and it tells React that the variable has a new value….so React will “react” to state changing and it will re-render your component.
CLICK HERE to find out more related problems solutions.