I got a Reactjs code of a class, which saves an array of data per instance. There is a method like addData(data)
which just pushes the new data to the array. I have also got a call to setInterval
with an action which is supposed to use the data every few seconds, and then delete everything by setting the array to an empty one.
Is there a need in a React app to synchronize the data and protect it with something like a lock in other languages which uses multi threading? If I do need to synchronize the data, how do I do it in React?