logux / client

Logux base components to build web client
https://logux.org/
MIT License
656 stars 46 forks source link

Some store updates could be skipped due to subscription in async `useEffect` #86

Closed AleksandrSl closed 2 years ago

AleksandrSl commented 2 years ago

Order of events during reproduction:

I believe thins like this bug is the reason why other state managers use synchronous useLayoutEffect e.g. effector and storeon. We don't have so much code in this effect for it to delay render. So it could be synchronous.

Another fix is to forceRender component after useEffect is done if the store value was changed during this time. But it will require more logic.

This bug is also fixed by React18 may be due to their changes in the rendering pipeline. Nonetheless, I think that a synchronous subscription for changes is better.

AleksandrSl commented 2 years ago

Closed by #87