Complete the code to define a CatchBoundary component that receives caught errors.
export function CatchBoundary() {
const caught = [1]();
return <div>Caught status: {caught.status}</div>;
}The useCatch hook is used inside CatchBoundary to access the caught response.
Complete the code to display the caught status code inside the CatchBoundary.
export function CatchBoundary() {
const caught = useCatch();
return <h1>Error [1]</h1>;
}The caught.status contains the HTTP status code of the caught response.
Fix the error in the CatchBoundary to correctly render the caught status and message.
export function CatchBoundary() {
const caught = useCatch();
return (
<div>
<h2>Status: [1]</h2>
<p>{caught.data.message}</p>
</div>
);
}The correct property for the status code in the caught object is status.
Fill both blanks to render a friendly message for 404 and 401 errors inside CatchBoundary.
export function CatchBoundary() {
const caught = useCatch();
return (
<div>
{caught.status === [1] && <p>Page not found.</p>}
{caught.status === [2] && <p>Unauthorized access.</p>}
</div>
);
}HTTP status 404 means 'Not Found' and 401 means 'Unauthorized'.
Fill all three blanks to create a CatchBoundary that shows status, statusText, and a retry button.
export function CatchBoundary() {
const caught = useCatch();
return (
<main>
<h1>Error [1]: [2]</h1>
<button onClick={() => window.location.[3]()}>Try again</button>
</main>
);
}The caught.status and caught.statusText show the error code and text. The reload method refreshes the page.
