I want to insert user data values into the form, but they do not have a successful validation status
Added values for fields to the form via useEffect
useEffect(() => {
if (auth) {
form.setFields(initialPersonalFields)
}
}, [])
The value itself is displayed in the fields, but they do not receive the status of validated and are not styled accordingly, although the submission with the validation check processes correctly and sees them as validated and does not throw an error. If you start writing in these fields, they also begin to work correctly; when necessary, it gives an error; when I fill it in manually, it correctly sets the status to “success”
Antd form values are only auto validated on change and on submit events, when you fill form values it will not validate these values until one of these events happens or if you force validation with form.validateFields()
, so your code should look something like this:
useEffect(() => {
// do nothing if auth is invalid
if (!auth) return
form.setFields(initialPersonalFields)
form.validateFields()
}, [])