Update gets triggered on render with initialValues
See original GitHub issueAre you submitting a bug report or a feature request?
Not sure if it’s a bug or a if it works as intended
What is the current behavior?
Updates are triggered once when then the form is rendered, i.e. even though no changes have been made to the form values.
See https://codesandbox.io/s/0ml4k745x0
What is the expected behavior?
I would expect updates to be triggered only on updates, not by the initial values.
What’s your environment?
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-final-form": "^4.0.2",
"final-form": "^4.11.0",
"final-form-calculate": "^1.3.0"
Issue Analytics
- State:
- Created 5 years ago
- Reactions:18
- Comments:12
Top Results From Across the Web
reduxForm - initialValues did not apply after update
I have a form component which get's it's "initialValues" via a "mapStateToProps" function. On the first render everything works quite fine.
Read more >Core — Jotai, primitive and flexible state management for React
initialValue : the initial value that the atom will return until its value is changed. read : a function that's called on every...
Read more >The Complete Guide to useRef() and Refs in React
Updating the reference value countRef.current++ doesn't trigger component re-rendering. This is demonstrated by the fact that 'I rendered!'
Read more >Basic Hooks - React Hooks Testing Library
NOTE: There's a gotcha with updates. renderHook mutates the value of current when updates happen so you cannot destructure its values as the...
Read more >Final Form Docs – `FieldProps`
If false , format will be called on every render. initialValue. any. Optional. The initial value for the field. This value will be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Interesting. This does not happen, when you specify the field as a regex. And, it gets triggered, but it seems that the changes won’t be applied to the values.
Came across this, because I’m looking for a way to do a initial calculation with the initial values
@cordial, I got to work around this by wrapping createDecorator function in my own really small decorator that returns the original decorator called with form as its argument. In the updates property you can now access form and check if it is pristine. If it is, simply return an empty object 😃
Instead of writing
you can write