ant-design / ant-design

An enterprise-class UI design language and React UI library
https://ant.design
MIT License
90.41k stars 46.39k forks source link

useWatch value get frozen inside columns render function #48659

Closed ndtnguyen closed 2 weeks ago

ndtnguyen commented 2 weeks ago

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Screenshot 2024-04-26 at 15 48 55
  1. Initialize the dataSource through form values with 1 row.
  2. Click 'Add'
  3. Click 'Delete' on any row

What is expected?

Selected row should be deleted

What is actually happening?

Environment Info
antd 5.16.0
React 17.0.2
System Mac Sonoma 14.3
Browser Chrome

When using watch value outside of column render function, it still works perfectly fine, it return the latest value of dataSource (which you can see in addRow())

zombieJ commented 2 weeks ago

Thanks for feedback but this is not related with antd.

The implementation of the deleteRow method as a closure within your code cause the data locking issue. We kindly suggest exploring some resources on closures knowledge to help resolve this.

github-actions[bot] commented 2 weeks ago

Hello @ndtnguyen, we use GitHub issues to trace bugs or discuss plans of Ant Design. So, please don't ask usage questions here. You can try to open a new discussion in antd discussions, select Q&A to ask questions, also can ask questions on Stack Overflow or Segment Fault, then apply tag antd and react to your question.

你好 @ndtnguyen,Ant Design Issue 板块是用于 bug 反馈与需求讨论的地方。请勿询问如何使用的问题,你可以试着在 antd discussions 新开一个 discussion,选择 Q&A 类别进行提问,也可以在 Stack Overflow 或者 Segment Fault 中提问(记得添加 antdreact 标签哦~)。