Skip to content

Commit

Permalink
feat: access action data in remix example
Browse files Browse the repository at this point in the history
  • Loading branch information
airjp73 committed Jun 14, 2024
1 parent 69567ad commit 9ad8f74
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/docs-v2/app/examples/basic/remix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ export const action = async ({ request }: ActionFunctionArgs) => {
};

export const ReactExample = () => {
const data = useActionData<typeof action>();
const form = useForm({
validator,
defaultValues: {
projectName: "",
tasks: [] as Array<{ title: string; daysToComplete: number }>,
},
onSubmitSuccess: () => {
showToastMessage("Project created!");
// We know this isn't an error in the success callback, but Typescript doesn't
if (isValidationErrorResponse(data)) return;

showToastMessage(`Project ${data?.projectName} created!`);
form.resetForm();
},
});
Expand Down

0 comments on commit 9ad8f74

Please sign in to comment.