Я следую этому коду:
import React from 'react';
import { Formik, Form, Field, FieldArray } from 'formik';
// Here is an example of a form with an editable list.
// Next to each input are buttons for insert and remove.
// If the list is empty, there is a button to add an item.
export const FriendList = () => (
<div>
<h1>Friend List</h1>
<Formik
initialValues = {{ friends: ['jared', 'ian', 'brent'] }}
onSubmit = {values =>
setTimeout(() => {
alert(JSON.stringify(values, null, 2));
}, 500)
}
render = {({ values }) => (
<Form>
<FieldArray
name = "friends"
render = {arrayHelpers => (
<div>
{values.friends && values.friends.length > 0 ? (
values.friends.map((friend, index) => (
<div key = {index}>
<Field name = {`friends.${index}`} />
<button
type = "button"
onClick = {() => arrayHelpers.remove(index)} // remove a friend from the list
>
-
</button>
<button
type = "button"
onClick = {() => arrayHelpers.insert(index, '')} // insert an empty string at a position
>
+
</button>
</div>
))
) : (
<button type = "button" onClick = {() => arrayHelpers.push('')}>
{/* show this when user has removed all friends from the list */}
Add a friend
</button>
)}
<div>
<button type = "submit">Submit</button>
</div>
</div>
)}
/>
</Form>
)}
/>
</div>
);
Но это для поля ввода текста.
Хочу заменить на select и как то так делаю.
Заменять:
<Field name = {`issues.${index}`} />
К:
<Field component = "select" name = "color">
<option value = "red">Red</option>
<option value = "green">Green</option>
<option value = "blue">Blue</option>
</Field>
Я добавляю 3 компонента, когда выбираю значение в одном компоненте, это влияет на все компоненты.
Что я здесь не так?



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Свойство name для каждого входа select должно быть уникальным. Попробуйте следующее
<Field component = "select" name = {`friends.${index}`}>
<option value = "red">Red</option>
<option value = "green">Green</option>
<option value = "blue">Blue</option>
</Field>