react-async-component icon indicating copy to clipboard operation
react-async-component copied to clipboard

Add a method to retry resolution and pass it to error component

Open nathanstitt opened this issue 7 years ago • 3 comments

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 <Retry> 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.

nathanstitt avatar Nov 22 '17 21:11 nathanstitt

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 Files Coverage Δ
src/asyncComponent.js 96.05% <100%> (+3.09%) :arrow_up:

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.

codecov[bot] avatar Nov 22 '17 21:11 codecov[bot]

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.

hochem avatar Dec 11 '17 15:12 hochem

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

mgreer avatar Aug 26 '18 23:08 mgreer