A React img component like React.Suspense!
Actually, its all props are same as
You should pass a react element to
When image are still pending, it'll show fallback element.
$ yarn add img-suspense
import ImgSuspense from 'img-suspense';<ImgSuspense="./cutecat.jpg"="cat"==/>
Error Boundary vs onError
There's an example show how to handle exception.
<ErrorBoundary><ImgSuspense ="./path/picuture.jpg" = /></ErrorBoundary>
If the img fails to load (for example, due to network failure), it will trigger an error.
You can handle these errors to show a nice user experience and manage recovery with Error Boundaries.
That's a same way you handle React.suspense exception.
Use onError to catch
You can just override onError handler to prevent component exception, treat it like an img element!
LICENSE MIT © 2019 realdennis