Skip to content

Commit 75f512b

Browse files
authored
Merge branch 'master' into fix/copy-button-responsive
2 parents 0ae75ec + a8fad1a commit 75f512b

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

src/components/ApiGallery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function ApiGallery() {
1818

1919
if (version !== 7) {
2020
router.push(
21-
`https://react-hook-form-website-git-leagcy-hook-form.vercel.app/${version}/api`
21+
`https://react-hook-form-website-git-leagcy-hook-form.vercel.app/v${version}/api`
2222
)
2323
} else {
2424
router.push(`/v${version}/docs/`)

src/content/advanced-usage.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ function App() {
381381

382382
<Input {...register("input")} />
383383

384-
<button type="button" onClick={() => reset({ defaultValues })}>
384+
<button type="button" onClick={() => reset({ ...defaultValues })}>
385385
Reset
386386
</button>
387387
<input type="submit" />
@@ -408,7 +408,7 @@ function App() {
408408
const onSubmit = (data) => console.log(data)
409409

410410
useEffect(() => {
411-
register({ name: "select" })
411+
register("select")
412412
}, [register])
413413

414414
const handleChange = (e) => setValue("select", e.target.value)
@@ -521,7 +521,12 @@ const items = Array.from(Array(1000).keys()).map((i) => ({
521521
const WindowedRow = memo(({ index, style, data }) => {
522522
const { register } = useFormContext()
523523

524-
return <input {...register(`${index}.quantity`)} />
524+
return (
525+
<div style={style}>
526+
<label>{data[index].title}</label>
527+
<input {...register(`${index}.quantity`)} />
528+
</div>
529+
)
525530
})
526531

527532
export const App = () => {

src/content/faqs.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,11 @@ export default function App() {
168168
const onSubmit = (data) => console.log(data)
169169
const { ref, ...rest } = register("firstName")
170170
const onClick = () => {
171-
firstNameRef.current!.value = ""
171+
firstNameRef.current.value = ""
172172
}
173173

174174
useImperativeHandle(ref, () => firstNameRef.current)
175175

176-
177176
return (
178177
<form onSubmit={handleSubmit(onSubmit)}>
179178
<input {...rest} ref={firstNameRef} />
@@ -207,7 +206,7 @@ export default function App() {
207206
useEffect(() => {
208207
register("firstName", { required: true })
209208
register("lastName")
210-
}, [])
209+
}, [register])
211210

212211
return (
213212
<form onSubmit={handleSubmit(onSubmit)}>
@@ -240,18 +239,11 @@ Make sure you are not using `value`. The correct property is `defaultValue`.
240239

241240
React Hook Form is focusing on uncontrolled inputs, which means you don't need to change the input `value` via `state` via `onChange`. In fact, you don't need `value` at all. You only need to set `defaultValue` for the initial input value.
242241

243-
```javascript
244-
import { useForm } from "react-hook-form/dist/index.ie11" // V6
245-
import { useForm } from "react-hook-form/dist/react-hook-form.ie11" // V5'
246-
// Resolvers
247-
import { yupResolver } from "@hookform/resolvers/dist/ie11/yup"
248-
```
249-
250242
---
251243

252244
## React Hook Form, Formik or Redux Form? {#ReactHookFormFormikorReduxForm}
253245

254-
First of all, all libs try to solve the same problem: make the form building experience as easy as possible. However, there are some fundamental differences between these three. `react-hook-form` is built with uncontrolled inputs in mind and tries to provide your form with the best performance and least amount of re-renders possible. Additionallly, `react-hook-form` is built with React Hooks and used as a hook, which means there is no Component for you to import. Here are some of the detailed differences:
246+
First of all, all libs try to solve the same problem: make the form building experience as easy as possible. However, there are some fundamental differences between these three. `react-hook-form` is built with uncontrolled inputs in mind and tries to provide your form with the best performance and least amount of re-renders possible. Additionally, `react-hook-form` is built with React Hooks and used as a hook, which means there is no Component for you to import. Here are some of the detailed differences:
255247

256248
| | React Hook Form | Formik | Redux Form |
257249
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
@@ -303,7 +295,7 @@ It's important to understand that React Hook Form embraces native form behavior
303295
- [Modal form and toggle inputs example](https://codesandbox.io/s/react-hook-form-modal-form-conditional-inputs-c7n0r)
304296
- [Tab form example](https://codesandbox.io/s/tabs-760h9)
305297

306-
Alternatively you can use the deprecated option `shouldUnregister: false` when calling \`useForm\`.
298+
Alternatively you can use the deprecated option `shouldUnregister: false` when calling `useForm`.
307299

308300
<TabGroup buttonLabels={["Controller", "Custom Register"]}>
309301

src/content/ts.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ export default function App() {
101101

102102
return (
103103
<form onSubmit={handleSubmit(onSubmit, onError)}>
104-
<input {...(register("firstName"), { required: true })} />
105-
<input {...(register("lastName"), { minLength: 2 })} />
104+
<input {...register("firstName", { required: true })} />
105+
<input {...register("lastName", { minLength: 2 })} />
106106
<input type="email" {...register("email")} />
107107

108108
<input type="submit" />
@@ -547,7 +547,7 @@ export type FormStateProxy<TFieldValues extends FieldValues = FieldValues> = {
547547
548548
```tsx copy sandbox="https://codesandbox.io/s/react-hook-form-nestedvalue-lskdv"
549549
import { useForm, NestedValue } from "react-hook-form"
550-
import { Autocomplete, TextField, Select } from "@material-ui/core"
550+
import { TextField, Select } from "@material-ui/core"
551551
import { Autocomplete } from "@material-ui/lab"
552552

553553
type Option = {
@@ -602,7 +602,7 @@ export default function App() {
602602

603603
<Select
604604
value=""
605-
onChange={(e) => setValue("muiSelect", e.target.value as number[])}
605+
onChange={(e) => setValue("select", e.target.value as number[])}
606606
>
607607
<MenuItem value={10}>Ten</MenuItem>
608608
<MenuItem value={20}>Twenty</MenuItem>

0 commit comments

Comments
 (0)