import type { LoaderFunction } from "@remix-run/node"; import { json } from "@remix-run/node"; import { useLoaderData } from "@remix-run/react"; import type { Note } from "@prisma/client"; import { db } from "~/utils/db.server"; type LoaderData = { notes: Array }; export const loader: LoaderFunction = async () => { const data: LoaderData = { notes: await db.note.findMany(), }; return json(data); }; export default function Index() { const data = useLoaderData(); return (

Welcome to Remix Heroku

Notes:

    {data.notes.map(({ id, name }) => (
  • id: {id} name: {name}
  • ))}
); }