Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:wellyshen/react-cool-form
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Dec 16, 2020
2 parents 3b5bb9c + 9a3225f commit c27fe1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/field-level-validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<form ref={form} noValidate>
<input name="username" placeholder="Username" ref={field(validateName)} />
Expand Down
4 changes: 3 additions & 1 deletion examples/form-level-validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<form ref={form} noValidate>
<input name="username" placeholder="Username" />
Expand Down

0 comments on commit c27fe1d

Please sign in to comment.