Notice: file_put_contents(): Write of 16751 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
Frontender Libs - обзор библиотек JS / CSS@sWebDev P.3140
SWEBDEV Telegram 3140
Использование useFieldArray в React

useFieldArray — это хук из библиотеки React Hook Form, помогающий управлять массивами полей в динамических формах.

Пример:
import React from 'react';
import { useForm, useFieldArray, Controller } from 'react-hook-form';

function DynamicForm() {
const { control, handleSubmit } = useForm({ defaultValues: { items: [''] } });
const { fields, append, remove } = useFieldArray({ control, name: 'items' });

return (
<form onSubmit={handleSubmit(console.log)}>
{fields.map((field, index) => (
<div key={field.id}>
<Controller
name={`items[${index}]`}
control={control}
render={({ field }) => <input {...field} />}
/>
<button type="button" onClick={() => remove(index)}>Удалить</button>
</div>
))}
<button type="button" onClick={() => append('')}>Добавить элемент</button>
<input type="submit" />
</form>
);
}

export default DynamicForm;

👉 @sWebDev
👍3



tgoop.com/sWebDev/3140
Create:
Last Update:

Использование useFieldArray в React

useFieldArray — это хук из библиотеки React Hook Form, помогающий управлять массивами полей в динамических формах.

Пример:

import React from 'react';
import { useForm, useFieldArray, Controller } from 'react-hook-form';

function DynamicForm() {
const { control, handleSubmit } = useForm({ defaultValues: { items: [''] } });
const { fields, append, remove } = useFieldArray({ control, name: 'items' });

return (
<form onSubmit={handleSubmit(console.log)}>
{fields.map((field, index) => (
<div key={field.id}>
<Controller
name={`items[${index}]`}
control={control}
render={({ field }) => <input {...field} />}
/>
<button type="button" onClick={() => remove(index)}>Удалить</button>
</div>
))}
<button type="button" onClick={() => append('')}>Добавить элемент</button>
<input type="submit" />
</form>
);
}

export default DynamicForm;

👉 @sWebDev

BY Frontender Libs - обзор библиотек JS / CSS




Share with your friend now:
tgoop.com/sWebDev/3140

View MORE
Open in Telegram


Telegram News

Date: |

A new window will come up. Enter your channel name and bio. (See the character limits above.) Click “Create.” Over 33,000 people sent out over 1,000 doxxing messages in the group. Although the administrators tried to delete all of the messages, the posting speed was far too much for them to keep up. Hui said the messages, which included urging the disruption of airport operations, were attempts to incite followers to make use of poisonous, corrosive or flammable substances to vandalize police vehicles, and also called on others to make weapons to harm police. The Channel name and bio must be no more than 255 characters long In the next window, choose the type of your channel. If you want your channel to be public, you need to develop a link for it. In the screenshot below, it’s ”/catmarketing.” If your selected link is unavailable, you’ll need to suggest another option.
from us


Telegram Frontender Libs - обзор библиотек JS / CSS
FROM American