Skip to content

issue: Form doesn't automatically revalidate when values prop changes #13123

@schuma7

Description

@schuma7

Version Number

7.66.0

Codesandbox/Expo snack

https://codesandbox.io/p/devbox/goofy-grothendieck-lg2sz9

Steps to reproduce

  1. Create a form using useForm with the values prop (controlled mode)
  2. Initially set values to undefined or an incomplete object
  3. Asynchronously load data and update the values prop with complete, valid data
  4. Observe that formState.isValid doesn't update automatically

Workaround

Currently, we need to manually trigger validation in a useEffect when the values prop changes:

useEffect(() => {
    if (formValues) {
        void form.trigger();
    }
}, [form, formValues]);

Expected behaviour

When the values prop changes (e.g., when data is loaded asynchronously), the form should automatically revalidate and update formState.isValid accordingly, without requiring manual intervention.

Please note that this used to work up until v7.65.0, it seems as if this regression was introduced with v7.66.0.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions