From 6832655b0ad51d9dc6b0dacfc270dadf217c4b03 Mon Sep 17 00:00:00 2001 From: Welly Date: Wed, 16 Dec 2020 13:33:39 +0800 Subject: [PATCH 1/2] chore(examples): update form-level validation --- examples/form-level-validation/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/form-level-validation/index.js b/examples/form-level-validation/index.js index 8f581c00..473251b2 100644 --- a/examples/form-level-validation/index.js +++ b/examples/form-level-validation/index.js @@ -29,13 +29,15 @@ const validate = async ({ username, email }) => { }; function App() { - const { form } = useForm({ + const { form, getState } = useForm({ defaultValues: { username: "", email: "" }, validate, onSubmit: (values) => alert(JSON.stringify(values)), onError: (errors) => console.log("onError: ", errors) }); + console.log("Form is validating: ", getState("isValidating")); + return (
From 9a3225fca07f57486f4d1bbc04a55e4e274926b8 Mon Sep 17 00:00:00 2001 From: Welly Date: Wed, 16 Dec 2020 13:34:48 +0800 Subject: [PATCH 2/2] chore(examples): update field-level validation --- examples/field-level-validation/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/field-level-validation/index.js b/examples/field-level-validation/index.js index 27143109..b243e6f8 100644 --- a/examples/field-level-validation/index.js +++ b/examples/field-level-validation/index.js @@ -27,12 +27,14 @@ const validateName = async (value) => { }; function App() { - const { form, field } = useForm({ + const { form, field, getState } = useForm({ defaultValues: { username: "", email: "" }, onSubmit: (values) => alert(JSON.stringify(values)), onError: (errors) => console.log("onError: ", errors) }); + console.log("Form is validating: ", getState("isValidating")); + return (