atlassian / react-sweet-state

Shared state management solution for React
https://atlassian.github.io/react-sweet-state/
MIT License
871 stars 55 forks source link

fix: correct nested batch behavior. #218

Open theKashey opened 1 year ago

theKashey commented 1 year ago

Solves #217

albertogasparin commented 12 months ago

Thanks! I guess this should be only relevant with React < 18. What do you think is the risk of such change now given that we are already updating to R18?

theKashey commented 12 months ago

I guess this should be only relevant with React < 18

Why? Right now the real problem is the first scheduled update will be executed after every following update and React 18's ability to batch updates will not change this.

Also, with some locations still using legacy Context API this change is the only opportunity to synchronise the mess - with one's ability to use batch to execute a given callback after all other scheduled events.

albertogasparin commented 12 months ago

Right, I see what you mean, missed the early return condition 👍