final-form / final-form

🏁 Framework agnostic, high performance, subscription-based form state management

Home Page:https://final-form.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FormAPI `initialize` vs `reset` docs are confusing.

tranvansang opened this issue · comments

Are you submitting a bug report or a feature request?

feature request (document enhancement)

What is the current behavior?

Document on FormApi.initialize and FormApi.reset are confusing readers.

docs url

For example, if I want to reset a form to a new state, while keeping dirty values as them are. Should I use initialize or reset?

Do these apis couple with FormProps.keepDirtyOnReinitialize. If yes, why do we have The form will be pristine after this call in the description of FormApi.initialize?

Am I correct if I consider initialize is reset with forcing keepDirtyOnReinitialize being false?
If I am, why does the docs say All the values will be set to these values, and dirty and pristine will be calculated by performing a shallow-equals between the current values and the values last initialized with? Since, if this call forces resetting all fields, dirty and pristine are always false and true, respectively. Is calculated word redundant in this context?

What is the expected behavior?

Sandbox Link

What's your environment?

Other information

Another question, what will happen if I call reset twice as followed?

///initialValues is `undefined`
reset({foo: 'bar'})
reset() // will this reset the form to `undefined` or {foo: 'bar'}

Why does the parameter of initialize is required, while initialValues option of the config object is optional? Is there any way to set initialValues to undefined via initialize?