ctrlplusb / react-async-component

Resolve components asynchronously, with support for code splitting and advanced server side rendering use cases.
MIT License
1.45k stars 62 forks source link

Prevent an infinite loop in browsers when an error happens in resolve #60

Closed xzyfer closed 6 years ago

xzyfer commented 6 years ago

Whenever an error occurs resolving a component this.state.error = true, however handling the error happens too late. As a result in an environment where typeof window !== 'undefined' i.e. the browser, this results in an infinite render loop.

This PR hoists the error handling earlier in the render call.

Fixes #42

ctrlplusb commented 6 years ago

Really excellent stuff here @xzyfer! Thanks so much for this.

I am gonna try pull it down and have a play but so far it LGTM.

❤️

jfsiii commented 6 years ago

Confirming that this work for me