Skip to content

Instantly share code, notes, and snippets.

View DennisKraaijeveld's full-sized avatar
🚀
Working on Site.nu

Dennis Kraaijeveld DennisKraaijeveld

🚀
Working on Site.nu
  • The Netherlands
  • 17:15 (UTC +02:00)
View GitHub Profile
/**
* Generic hook for submitting data via fetcher using FormData.
* Relies on React Router 7's type generation for the action's return type.
*
* @template TSchema - The Zod schema type for input data validation and type inference.
* @template TActionReturn - The specific return type of the target route's action function (inferred via RR7 typegen).
* @param _schema - Zod schema (used primarily for type inference of the 'data' in submit).
* @param actionUrl - The target URL for the fetcher submission.
* @param prepareFormData - A function that takes the typesafe data object (z.infer<TSchema>) and returns a FormData instance.