final-form / final-form/react-final-form-listeners

OnChange function is called on every render instead of user interaction.

Open
#7 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
95
Forks
21
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’m using this inside a field array, I basically want to reset an input text field on change of a dropdown/select field item. It works fine as expected. But when I delete that row, the field-array template is re-rendered that causes the onChange of the dropdown in each row to execute again that resets the other selections made by the user.

### What is the expected behaviour?
The expected behaviour is that the onChange handler should only be called when a user performs a change to the input/select. It shouldn't be called by re-render of FieldArray.

I've followed the example that is [mentioned here](https://medium.com/@erikras/declarative-form-rules-c5949ea97366): It says that "It’s important to notice that the function given to OnChange will only be called when the value changes, not on every render."

### Sandbox Link

### What's your environment?

"react": "^16.3.2",
"react-apollo": "^2.3.1",
"react-beautiful-dnd": "^9.0.2",
"react-dom": "^16.3.2",
"react-final-form": "^3.6.2",
"react-final-form-listeners": "^1.0.1",
"react-final-form-arrays": "^1.0.6"
Mac - Chrome Browser Version 70.0.3538.110 (Official Build) (64-bit)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.