Skip to content

[Bug v7.0.0] useField returns undefined value on initial render despite initialValues being set #1050

@yurii-oliiarnyk-finsight

Description

Description

Hi, thanks for your work on the library!

We're encountering a blocking issue when trying to migrate to [email protected] to prepare for React 19.

Problem

When initialValues are passed to the <Form />, the corresponding fields registered via useField initially return value: undefined. This was not the case in earlier versions.

It seems that the field state is now derived via form.getFieldState() during initialization here — but this runs before the field is registered here, so the field state is not available at that moment.

As a result:

Fields render with value: undefined on the first render. Components relying on the initial value (e.g., to initialize local state or trigger effects) fail or misbehave.

Expect result:

Fields render with defined value on initialize as it was before in v6.5.9

Sandbox Link

v6.5.9 https://codesandbox.io/p/sandbox/h7lk86
Logs:
Image

v7.0.0 https://codesandbox.io/p/sandbox/6cd2fz
Logs:
Image

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