Summary
In this chapter, you learned that Remix lets us handle both expected and unexpected failures declaratively using Remix’s ErrorBoundary
component.
The root ErrorBoundary
export handles thrown responses and errors if no other nested error boundary has handled them yet. Both errors and thrown responses bubble upward through the route hierarchy.
Then, you learned that error boundaries do not have access to loader data. It is important not to render any components in the boundaries that access the useLoaderData
hook.
Using error boundaries makes the application more resilient toward errors. Tight error boundaries keep parts of our application functional if an unexpected error only affects a nested route module.
In the next chapter, we will throw some more responses – 401 responses, to be precise – as we implement an authentication flow and learn more about state management with Remix.