Open
Description
What is the current behavior?
If a hook make the component re-render, then the prevValues will be an empty object and the "updates" function are triggered even if the values did not change
What is the expected behavior?
The "update" function should probably not be triggered, but they are probably because the prevValues is an empty object, which should not happen either
Sandbox Link
My current fix
const decorator = createDecorator({
field: 'foo',
updates: (fieldValue, fieldName, allValues, prevValues) => {
if (typeof prevValues[fieldName] === 'undefined') {
return {};
}
// do real stuff
}
})
Extracted from the final-form-calculate example: https://codesandbox.io/s/react-final-form-calculated-fields-forked-wpm4f?file=/index.js
What's your environment?
- final-form: 4.12.0
- final-form-calculate: 1.3.2
- react-final-form: 5.0.1
Metadata
Metadata
Assignees
Labels
No labels