handle 404 page in react router V7 framework #13701
Eng1Mahmoud
started this conversation in
Proposals
Replies: 1 comment 2 replies
-
You can just throw a 404 from your loader: export async function loader({ params }: Route.ActionArgs) {
let project = await fakeDb.getProject(params.id);
if (!project) {
// throw to ErrorBoundary
throw data(null, { status: 404 });
}
return project;
} And then check for it in your error boundary: (lifted from https://reactrouter.com/tutorials/address-book#the-root-route) if (isRouteErrorResponse(error)) {
message = error.status === 404 ? "404" : "Error";
details =
error.status === 404
? "The requested page could not be found."
: error.statusText || details;
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
how handle 404 page in react router V7 framework
Beta Was this translation helpful? Give feedback.
All reactions