Complete the code to import the ErrorBoundary component from Remix.
import { [1] } from "@remix-run/react";
The ErrorBoundary component is imported from @remix-run/react to handle errors in Remix routes.
Complete the code to define an error boundary component that receives the error as a prop.
export function ErrorBoundary({ [1] }) {
return <div>Something went wrong: {error.message}</div>;
}props without destructuring.children or data instead of error.The error boundary component receives an error prop that contains the error details.
Fix the error in the nested error boundary usage by completing the code to wrap the child component with an ErrorBoundary.
return ( <ErrorBoundary> <[1] /> </ErrorBoundary> );
ErrorBoundary inside itself.Link or useLoaderData instead of Outlet.The Outlet component renders child routes and should be wrapped by ErrorBoundary to catch errors in nested routes.
Fill both blanks to create a nested error boundary that catches errors in a specific child route and displays a fallback UI.
export function ChildErrorBoundary({ [1] }) {
return <div>Error in child route: {error.[2]</div>;
}props instead of destructuring error.stack or status instead of message.The child error boundary receives the error prop and displays its message property to show the error details.
Fill all three blanks to implement nested error boundaries with a parent and child, each showing different error messages.
export function ParentErrorBoundary({ [1] }) {
return (
<div>
<h2>Parent error: {error.[2]</h2>
<ErrorBoundary>
<ChildComponent />
</ErrorBoundary>
</div>
);
}
function ChildComponent() {
throw new Error("Child route failed");
}
export function ChildErrorBoundary({ [3] }) {
return <div>Child error: {error.message}</div>;
}props instead of destructuring error.The parent and child error boundaries both receive an error prop. The parent displays error.message, and the child also uses error to show its message.
