Skip to content

useWatch v6和v5版本行为不一致 #56230

@yinvoke

Description

@yinvoke

Reproduction link

https://github.com/yinvoke/form-list-use-watch-bug

Steps to reproduce

  1. 创建Form.List,并通过useWatch进行监听
  2. 添加2个元素,例如[1,2]
  3. 使用Form.List的remove删除第二个元素,此时监听值应该变为[1]
  4. 通过antd5版本remove后会变为监听值会变为[1],antd6版本remove后监听值会先变为[1,undefined]再变为[1]

What is expected?

useWatch监听值在remove后没有中间的状态,例如[1,2]在remove后直接变为[1],而不是[1,undefined]

What is actually happening?

useWatch监听值在remove后存在含undefined的中间态,例如[1,2]在remove后直接变为[1,undefined]再变为[1]

Environment Info
antd 6.1.0
React 19.2.0
System macos
Browser chrome

升级后使用FormList且使用监听的地方会导致异常问题,希望可以恢复antd5默认行为

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 BugAnt Design Team had proved that this is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions