-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
[Bug] Table组件hover每一行时会触发Table的重渲染 #32979
Comments
好像并不仅仅只是columns被重新渲染了,可以看看这个例子,每次hover到table中的某一行时都重新触发Table组件上的rowKey方法。 |
嗯,为了解决 Table 合并行 hover 样式做了渲染更新。现行的数据结构有点问题导致在渲染之前无法确定哪些节点被影响到,比较蛋疼。 |
暂时没有解决办法吗?感觉数据量起来了的话性能还是存在问题的 |
嗯,需要将 column.render 拆分。 |
This is really annoying and a huge performance hit. |
You can mitigate it a bit by implementing |
This would probably remove the ability to update the cells on MobX state change, unless i change all render methods to return the components that observe the values themselves, which would be a huge amount of work. I'm not sure why this change is implemented, as there is a perfectly functioning :hover state in CSS? |
The issue has already been fixed in rc-table. We do have a wrapper for antd table that just adds a |
Oh, cool, so the fix will probably land in ant in the upcoming weeks |
Temporary solution: if you're using
to your Related react-component/table#686 . And actually there's comment pointing the issue in the original PR |
I think |
这个倒是临时解决此类问题的好方法,学习了 |
That's right, but that case can be detected and this feature can only be applied to these rows. |
I think this is still active bug even in 4.18.3 |
in Body(
BodyRow(
Cell(
{props:hovering} // [`${cellPrefixCls}-row-hover`]: !cellProps && hovering,
)
)
) hover cell(onMouseEnter) => rerender all the cells to get the newest Instead of passing props to get a new classname, can we use web API eg I have done some local tests, using web API to control the element can improve the performance(prevent @afc163 @zombieJ what do you think? or can I submit a PR about these changes? |
Any update about this issue? How to fix re-renrer on row hover? |
@p-efimenko for now, i solved it by pinning rc-table component version. |
@DVSoftware thanks, I have seen this comment but, I don't use yarn :( |
You can use https://www.npmjs.com/package/npm-force-resolutions |
4.18.8 seems to have solved this problem in my project. |
这个会不会影响到antd表格功能 |
这个最终有什么好的解决方案呢 |
还有一种方法是在td上绑定一个ref, 然后在这个ref上绑定focusout事件,也可以在光标在hover到其他行的时候触发事件 import React, { useState } from 'react';
import { useEventListener } from 'ahooks';
export default () => {
const [value, setValue] = useState('');
useEventListener('keydown', (ev) => {
setValue(ev.code);
});
return <p>Your press key is {value}</p>;
}; |
This issue still exists in antd@5.9.2: if I pass custom |
@afc163 what about antd 5.x? |
重现链接
https://codesandbox.io/s/antd4-17-x-tablezu-jian-hoverxing-hui-chu-fa-chong-xuan-ran-wen-ti-fu-xian-slykl?file=/src/App.js
antd 版本
4.17.0
重现步骤
期望的结果是什么?
实际的结果是什么?
浏览器
Chrome
浏览器版本
96.0.4664.45
操作系统
Windows
其他
The text was updated successfully, but these errors were encountered: