Skip to content

Instantly share code, notes, and snippets.

@bekzodnj
bekzodnj / useFieldArrayMethods.ts
Last active January 22, 2023 12:20
React Hook Form's `useFieldArray` hook. Examples of append, prepend, insert (with focus options). CodeSandbox: https://codesandbox.io/s/react-hook-form-focus-options-fn6fqq
// CodeSandbox link: https://codesandbox.io/s/react-hook-form-focus-options-fn6fqq
export default function App() {
const { register, control } = useForm<{
test: { value: string }[];
}>({
defaultValues: {
test: [{ value: "1" }, { value: "2" }]
}
});