final-form / final-form/react-final-form-arrays
arrays get reset with pristine values on change
- Dominant language
- TypeScript
- Stars
- 210
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
### Are you submitting a **bug report** or a **feature request**?
Bug report
### What is the current behavior?
I have a form with the following characteristics:
My initial values are as follows:
```
{
apis: []
}
```
```
(
{render(renderProps)}
)}
/>
```
```
{({ fields }) => (
Select an API
Select an API
{Object.values(apiConstants)
.filter(
ky => !values.apis.find(el => el.api === ky.value)
)
.map(el => (
{el.key}
))}
{fields.map((name, index) => (
))}
)}
```
When I select an item in the Select component a `state` change occurs and the entire form resets with `keepDirtyOnReinitialize=false` or it keeps the changes with `keepDirtyOnReinitialize=true` but after adding a first `api`, the second `state` change causes the `api[0]` to be set to `undefined`.
### What is the expected behavior?
It should not reset form state on a state change.
### What's your environment?
```
"node": "8.12.0",
"react": "16.6.0",
"final-form": "4.11.0",
"final-form-arrays": "1.1.1",
"react-final-form": "4.0.2",
"react-final-form-arrays": "2.0.1",
```
Contributor guide
Research direction
Start by reproducing the provided Form and FieldArray example with the listed final-form, react-final-form, and array package versions. Trace what happens to the array when the Select causes a state change, and consider the issue done when existing array entries remain intact instead of being reset or becoming undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100