👉 NEW values
props
The following syntax will react to values
prop update/changes.
- values will be reactive to update/change and reset accordingly
- provide a reset option to keep dirty/touched values potentially
const values = await fetch('API')
useForm({
values, // will reset the form when values updates
// resetOptions: {
// keepDirtyValues: true
// }
})
👉 NEW async defaultValues
props
The following syntax will support async defaultValues
, so we will manage the reset
form internally and update formState
accordingly.
- promise will only be resolved once during
useForm()
call - It's possible to supply
resetOptions
as well
useForm({
defaultValues: fetch('API')
// resetOptions: {
// keepDirtyValues: true
// }
})
React use
API
useForm({
defaultValues: use(fetch('API'))
// resetOptions: {
// keepDirtyValues: true
// }
})
🙋 What's the difference between values
and defaultValues
values
will react to changes and reflect on the form values, and defaultValues
is cached for once and will never re-run the promise or react to defaultValues
changes.
🌻 close #9379 flush extra re-render at useFormState to update current form state subscription (#9380)
🍄 upgrade to TS4.9 (#9371)