Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

自定义Row组件,每次setState的时候tr都没有复用DOM,而是创建了新的tr(声明了primaryKey也没有用), 导致单元格文字无法选中。 #313

Open
laochake opened this issue Jun 9, 2022 · 1 comment

Comments

@laochake
Copy link

laochake commented Jun 9, 2022

复现demo地址:
https://codesandbox.io/s/react-playground-forked-o53wqr?file=/index.js:1417-1450

DOM断点调试可以看到tr被删除又重新创建了
image

@laochake
Copy link
Author

laochake commented Jun 9, 2022

已经解决,Row组件需要useCallback包一层, 然后点击事件/样式 不要与Row强关联,保持setState的时候Row组件是不变的,点击事件/样式等通过getRowProps来绑定,而不是生成一个新的Row FunctionComponent, 导致就算下层的tr key和type不变的情况下也会先卸载DOM再创建DOM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant