final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.39k stars 481 forks source link

I believe defaultValue should be the DEFAULT. That means, if NO initialValue was passed in, the defaultValue would be used. If there is an initialValue, it should override the defaultValue. One work around is using an OR in initialValues and skip using defaultValue all together like so: #1037

Open tulsiempyreal opened 1 year ago

tulsiempyreal commented 1 year ago
          I believe defaultValue should be the DEFAULT.  That means, if NO initialValue was passed in, the defaultValue would be used.  If there is an initialValue, it should override the defaultValue.  One work around is using an OR in initialValues and skip using defaultValue all together like so:

const initialValues = { name: item.name || defaultName }

The only problem with this if you need the field to be dirty like defaultValue sets it, you wont get it with this method.

Originally posted by @dprea in https://github.com/final-form/react-final-form/issues/387#issuecomment-509827508