Remix Logo
1.19.3
Branches
main (2.3.1)dev
Versions
2.3.11.19.3v0.21.0
Viewing docs for an older release. View latest
useLoaderData

useLoaderData

This hook is simply a re-export of React Router's useLoaderData.

Watch the 📼 Remix Single: Loading data into components

This hook returns the JSON parsed data from your route loader function.

import { json } from "@remix-run/node"; // or cloudflare/deno
import { useLoaderData } from "@remix-run/react";

export async function loader() {
  return json(await fakeDb.invoices.findAll());
}

export default function Invoices() {
  const invoices = useLoaderData<typeof loader>();
  // ...
}

For more information and usage, please refer to the React Router useLoaderData docs.

Docs and examples licensed under MIT