UofS-CEPHIL / modelcollab

A web-based application for collaborating on simulation models in real-time using Firebase
31 stars 1 forks source link

useState overwrites each other in firebaseDataModel.registerComponentRemovedListener() in Canvas #4

Closed longg-phamm closed 2 years ago

longg-phamm commented 2 years ago

When a Stock that has Flows is deleted, the associated Flows in React are not removed even though Firebase did remove them.

This is because the useState is async. useState will be called with a new set of Flows. But at the same time, another useState for Stocks is called and it has the old set of Flows. This overwrites the new set of Flows.

longg-phamm commented 2 years ago

This is fixed with the new design