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