Skip to content

Commit 28f4d2f

Browse files
committed
fix format
1 parent 2b6dbc7 commit 28f4d2f

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
pnpm-lock.yaml
1+
pnpm-lock.yaml
2+
.cache/
3+
.contentlayer/
4+
.next/

src/content/docs/useform/setvalue.mdx

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,32 @@ const App = () => {
121121
**Dependant Fields**
122122

123123
```typescript sandbox="https://codesandbox.io/s/dependant-field-dwin1"
124-
import * as React from "react";
125-
import { useForm } from "react-hook-form";
124+
import * as React from "react"
125+
import { useForm } from "react-hook-form"
126126

127127
type FormValues = {
128-
a: string;
129-
b: string;
130-
c: string;
131-
};
128+
a: string
129+
b: string
130+
c: string
131+
}
132132

133133
export default function App() {
134-
const { watch, register, handleSubmit, setValue, formState } = useForm<
135-
FormValues
136-
>({
137-
defaultValues: {
138-
a: "",
139-
b: "",
140-
c: ""
141-
}
142-
});
143-
const onSubmit = (data: FormValues) => console.log(data);
144-
const [a, b] = watch(["a", "b"]);
134+
const { watch, register, handleSubmit, setValue, formState } =
135+
useForm<FormValues>({
136+
defaultValues: {
137+
a: "",
138+
b: "",
139+
c: "",
140+
},
141+
})
142+
const onSubmit = (data: FormValues) => console.log(data)
143+
const [a, b] = watch(["a", "b"])
145144

146145
React.useEffect(() => {
147146
if (formState.touchedFields.a && formState.touchedFields.b && a && b) {
148-
setValue("c", `${a} ${b}`);
147+
setValue("c", `${a} ${b}`)
149148
}
150-
}, [setValue, a, b, formState]);
149+
}, [setValue, a, b, formState])
151150

152151
return (
153152
<form onSubmit={handleSubmit(onSubmit)}>
@@ -159,14 +158,14 @@ export default function App() {
159158
<button
160159
type="button"
161160
onClick={() => {
162-
setValue("a", "what", { shouldTouch: true });
163-
setValue("b", "ever", { shouldTouch: true });
161+
setValue("a", "what", { shouldTouch: true })
162+
setValue("b", "ever", { shouldTouch: true })
164163
}}
165164
>
166165
trigger value
167166
</button>
168167
</form>
169-
);
168+
)
170169
}
171170
```
172171

0 commit comments

Comments
 (0)