Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为何table设置value后会执行2次渲染? #10

Open
wittech opened this issue Feb 15, 2022 · 7 comments
Open

为何table设置value后会执行2次渲染? #10

wittech opened this issue Feb 15, 2022 · 7 comments

Comments

@wittech
Copy link

wittech commented Feb 15, 2022

为何table设置value后会执行2次渲染?性能不太理想啊

@JSchmidt63
Copy link

maybe same problem? see: ant-design/ant-design#33942

@wittech
Copy link
Author

wittech commented Feb 16, 2022

发现是MyTable代码中的这行导致的2次渲染:
const recursiveRow = getRecursiveRow(value, tableConfig);

@wittech
Copy link
Author

wittech commented Feb 16, 2022

@JSchmidt63 一个是整个组件渲染2次,发现应该是代码里面在给value设置_expand等属性导致的,还有就是onCell渲染2次整体导致非常卡顿

@wittech
Copy link
Author

wittech commented Feb 16, 2022

@JSchmidt63 有什么好的建议,在MyTable内部执行getRecursiveRow后避免2次渲染?

@wittech
Copy link
Author

wittech commented Feb 16, 2022

@JSchmidt63
const recursiveRow = untracked(() => getRecursiveRow(value, tableConfig));
const rowSelection = untracked(() => getRowSelection(value, tableConfig));
发现这两句会导致value改变从而触发重新渲染,我加了个untracked是否可行?会不会引发别的问题?

@fishedee
Copy link
Owner

@wittech 我觉得你这个方案可以,提个PR,我合并进去

@wittech
Copy link
Author

wittech commented Feb 17, 2022

好的我整理一下

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

No branches or pull requests

3 participants