Skip to content

Commit 36c1485

Browse files
author
den025
committed
docs: Update handleSubmit error handling example with setError usage
1 parent 5aae1a2 commit 36c1485

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/content/docs/useform/handlesubmit.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ This function will receive the form data if form validation is successful.
3838
// await fetch()
3939
} catch (e) {
4040
// handle your error
41+
setError("service", {
42+
type: "custom",
43+
message: "something went wrong",
44+
})
4145
}
4246
}
4347

src/data/api.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,10 @@ handleSubmit(async (data) => await fetchAPI(data))`}
967967
// await fetch()
968968
} catch (e) {
969969
// handle your error
970+
setError("service", {
971+
type: "custom",
972+
message: "something went wrong",
973+
})
970974
}
971975
};
972976

0 commit comments

Comments
 (0)