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.

  1. import { json } from "@remix-run/node"; // or cloudflare/deno
  2. import { useLoaderData } from "@remix-run/react";
  3. export async function loader() {
  4. return json(await fakeDb.invoices.findAll());
  5. }
  6. export default function Invoices() {
  7. const invoices = useLoaderData<typeof loader>();
  8. // ...
  9. }

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