FormidableLabs / react-ssr-prepass

A custom partial React SSR renderer for prefetching and suspense
MIT License
592 stars 26 forks source link

Do not assert current identity in dispatchAction #51

Closed zenflow closed 4 years ago

zenflow commented 4 years ago

Fixes #19

From what I can see, the dispatchAction function is bound with the first two arguments, to become (for example) a setState function. This setState function can be called at any time; it doesn't need to be (and actually should not be) called within the body of a function component.

Therefore, in dispatchAction, it doesn't make sense to make the assertion that getCurrentIdentity() makes: https://github.com/FormidableLabs/react-ssr-prepass/blob/35fb629b99a7c608f795fa43f577ca7ba63fb192/src/internals/dispatcher.js#L26-L39

To prevent that assertion from happening inside dispatchAction, we can access currentIdentity directly.