Conversation

nathanstitt

I use react-async-component for loading web pack modules with import() and find that they sometimes will timeout or otherwise fail to load.

I'd like to add a button to my ErrorComponent but there wasn't a way to do so. This provides a function that could be called.

I've tested with simulated network timeout by putting Chrome offline and seems to work well.

I also added a spec and noticed a few things that could be improved there. Happy to rework if you spot anything else.

Makes running specs a bit neater without being interrupted by warnings
@codecov

Codecov Report

Merging #70 into master will increase coverage by 2.42%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #70      +/-   ##
=========================================
+ Coverage   94.38%   96.8%   +2.42%     
=========================================
  Files           3       3              
  Lines          89      94       +5     
  Branches       25      25              
=========================================
+ Hits           84      91       +7     
+ Misses          5       3       -2
Impacted FilesCoverage Δ
src/asyncComponent.js96.05% <100%> (+3.09%)⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94fc382...80c276a. Read the comment docs.

This way it can re-attempt resolution to work around network timeouts and such
@hochem

Any updates on this PR? I have the same problem (failed components will never resolve once networking is up again) and I would like to have this feature in the lib.

@mgreer

I implement this as an HOC wrapper around async, to retry with backoff:
https://gist..com/mgreer/eb33c95d22cabcec22a26b28acacaa16
Happy to contribute this as an option in the lib too.

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.