From 36c1485ed217d3b0aec457193d63154a08c3d31a Mon Sep 17 00:00:00 2001 From: den025 <> Date: Mon, 21 Apr 2025 17:43:53 -0700 Subject: [PATCH] docs: Update handleSubmit error handling example with setError usage --- src/content/docs/useform/handlesubmit.mdx | 4 ++++ src/data/api.tsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/content/docs/useform/handlesubmit.mdx b/src/content/docs/useform/handlesubmit.mdx index 93128ffe6..e5b811327 100644 --- a/src/content/docs/useform/handlesubmit.mdx +++ b/src/content/docs/useform/handlesubmit.mdx @@ -38,6 +38,10 @@ This function will receive the form data if form validation is successful. // await fetch() } catch (e) { // handle your error + setError("service", { + type: "custom", + message: "something went wrong", + }) } } diff --git a/src/data/api.tsx b/src/data/api.tsx index 2774765ec..53e01d6b8 100644 --- a/src/data/api.tsx +++ b/src/data/api.tsx @@ -967,6 +967,10 @@ handleSubmit(async (data) => await fetchAPI(data))`} // await fetch() } catch (e) { // handle your error + setError("service", { + type: "custom", + message: "something went wrong", + }) } };