-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathserver-function-arrow.tsx
More file actions
31 lines (27 loc) · 887 Bytes
/
server-function-arrow.tsx
File metadata and controls
31 lines (27 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Form, useActionData } from 'react-router';
import { submitFormArrow } from './actions';
import type { Route } from './+types/server-function-arrow';
export async function action({ request }: Route.ActionArgs) {
const formData = await request.formData();
return submitFormArrow(formData);
}
export default function ServerFunctionArrowPage() {
const actionData = useActionData<typeof action>();
return (
<main>
<h1>Server Function Arrow Test</h1>
<Form method="post">
<label htmlFor="name">Name:</label>
<input type="text" id="name" name="name" defaultValue="Arrow User" />
<button type="submit" id="submit">
Submit
</button>
</Form>
{actionData && (
<div data-testid="result">
<p data-testid="message">Message: {actionData.message}</p>
</div>
)}
</main>
);
}