本页还没有译文
本页 10 段还没译成简体中文,下面显示的是英文原文。useActionData
还没翻译译自英文(reactrouter.com)本页 10 段都还没译
useActionData
Framework Data
Summary
Returns the action data from
the most recent POST navigation form submission or undefined if there
hasn't been one.
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>
);
}Signature
function useActionData<T = any>(): SerializeFrom<T> | undefinedReturns
The data returned from the route's action
function, or undefined if no action
has been called
AI 翻译查看英文原文