Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

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

wants to merge 3 commits into from

Conversation

nathanstitt
Copy link

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
Copy link

codecov bot commented Nov 22, 2017

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%) ⬆️

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
Copy link

hochem commented Dec 11, 2017

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
Copy link

mgreer commented Aug 26, 2018

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants