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

Add ErrorCallback #35

Closed kennethtruong closed 7 years ago

kennethtruong commented 7 years ago

Fixes #29

I want to be able to log errors in sentry.io if the component ever throw an error. Because asyncComponents will catch errors in the render method the errors I might get in sentry are only the exceptions from React so I won't ever get the underlying cause.

I tried to use the ErrorComponent to handle the error but I realize that if there is an error is in the render method React doesn't seem to mount the ErrorComponent. Most likely my components won't throw an error in production but I would still want to be able to log the errors in the case that it does.

codecov[bot] commented 7 years ago

Codecov Report

Merging #35 into master will decrease coverage by 1.13%. The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #35      +/-   ##
==========================================
- Coverage   97.56%   96.42%   -1.14%     
==========================================
  Files           3        3              
  Lines          82       84       +2     
==========================================
+ Hits           80       81       +1     
- Misses          2        3       +1
Impacted Files Coverage Δ
src/asyncComponent.js 95.65% <75%> (-1.37%) :arrow_down:

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 9b5d788...f054a0b. Read the comment docs.