KELiON / redux-async-initial-state

Redux middleware that helps you load redux initial state asynchronously
MIT License
114 stars 12 forks source link

Race conditions occur when passing only the current state #11

Closed tuntisz closed 6 years ago

tuntisz commented 7 years ago

If any action occurs between redux-async-initial-state/STATE_LOADING_START and redux-async-initial-state/STATE_LOADING_DONE, currentState becomes out of sync.

By passing getState instead of getState(), developers are able to grab the latest store on promise resolution. https://github.com/KELiON/redux-async-initial-state/blob/master/src/middleware.js#L7

jdolle commented 7 years ago

I just encountered this as well. 100% need a way to get the current state, otherwise valuable data is getting removed from my store.

tuntisz commented 7 years ago

https://github.com/KELiON/redux-async-initial-state/pull/13