The data returned from the route's action
function, or undefined if no action
has been called
import { Form, useActionData } from "react-router";
export async function action({ request }) {
const body = await request.formData();
const name = body.get("visitorsName");
return { message: `Hello, ${name}` };
}
export default function Invoices() {
const data = useActionData();
return (
<Form method="post">
<input type="text" name="visitorsName" />
{data ? data.message : "Waiting..."}
</Form>
);
}
@public
Returns the
actiondata from the most recentPOSTnavigation form submission orundefinedif there hasn't been one.