Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"analyze": "cross-env ANALYZE=true next build",
"build": "next build",
"dev": "next dev",
"format": "prettier . --check",
"format": "prettier . --write",
"format:fix": "prettier . --write",
"lint": "next lint",
"lint:fix": "next lint --fix",
Expand Down
4 changes: 4 additions & 0 deletions src/components/CodeArea.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
background: none;
border: 1px solid transparent;
color: currentColor;
/* Keeps copy button visible on small screens */
display: flex;
align-items: center;
justify-content: center;
}

.active,
Expand Down
27 changes: 14 additions & 13 deletions src/content/docs/useformstate/errormessage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,18 @@ export default function App() {
```

```javascript copy sandbox="https://codesandbox.io/s/react-hook-form-v7-errormessage-multiple-error-messages-lnvkt"
import { useForm } from "react-hook-form";
import { ErrorMessage } from '@hookform/error-message';

import { useForm } from "react-hook-form"
import { ErrorMessage } from "@hookform/error-message"

export default function App() {
const { register, formState: { errors }, handleSubmit } = useForm({
criteriaMode: "all"
});
const onSubmit = data => console.log(data);
const {
register,
formState: { errors },
handleSubmit,
} = useForm({
criteriaMode: "all",
})
const onSubmit = (data) => console.log(data)

return (
<form onSubmit={handleSubmit(onSubmit)}>
Expand All @@ -172,12 +175,12 @@ export default function App() {
required: "This is required.",
pattern: {
value: /d+/,
message: "This input is number only."
message: "This input is number only.",
},
maxLength: {
value: 10,
message: "This input exceed maxLength."
}
message: "This input exceed maxLength.",
},
})}
/>
<ErrorMessage
Expand All @@ -191,12 +194,10 @@ export default function App() {
}
/>


<input type="submit" />
</form>
);
)
}

```

</TabGroup>
16 changes: 8 additions & 8 deletions src/content/docs/usewatch/watch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ A React Hook Form component that provides the same functionality as `useWatch`,
| `defaultValue` | <TypeText>unknown</TypeText> | default value for `useWatch` to return before the initial render.<br/><br/>**Note:** the first render will always return `defaultValue` when it's supplied. |
| `disabled` | <TypeText>boolean = false</TypeText> | Option to disable the subscription. |
| `exact` | <TypeText>boolean = false</TypeText> | This prop will enable an exact match for input name subscriptions. |
| `render` | <TypeText>Function</TypeText> | Subscribes to specified form field(s) and re-renders its child function whenever the values change. This allows you to declaratively consume form values in JSX without manually wiring up state. |
| `render` | <TypeText>Function</TypeText> | Subscribes to specified form field(s) and re-renders its child function whenever the values change. This allows you to declaratively consume form values in JSX without manually wiring up state. |

**Examples:**

---

```tsx copy sandbox=""
import { useForm, Watch } from 'react-hook-form';
import { useForm, Watch } from "react-hook-form"

const App = () => {
const { register, control } = useForm();
const { register, control } = useForm()

return (
<div>
<form>
<input {...register('foo')} />
<input {...register('bar')} />
<input {...register("foo")} />
<input {...register("bar")} />
</form>
{/* re-render only when value of `foo` changes */}
<Watch
control={control}
names={['foo']}
names={["foo"]}
render={([foo]) => <span>{foo}</span>}
/>
</div>
);
};
)
}
```
2 changes: 1 addition & 1 deletion src/content/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm install react-hook-form

## Example

The following code excerpt demonstrates a basic usage example:
The following code excerpt hello demonstrates a basic usage:

<TabGroup buttonLabels={["TS", "JS"]}>

Expand Down