Errors that occur if the fetch fails are thrown, so you can try/catch them.

try {
const response = useFetch(...);
catch (e) {
if (e instanceof Promise) {
throw e;
return <p>An error occurred!</p>;

Since Promises are also thrown, they must be rethrown if caught. I don’t think this behavior is as clean as it should be, but this is the same behavior you will find with React’s built-in componentDidCatch.

<LazyLoadedComponent />

In the above example, your component with componentDidCatch must throw any Promises that it catches in order for those Promises to “trickle up” to Suspense.

Suspense, similarly, rethrows errors that are not Promises.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store