question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hover behavior on top of JS for `Table` has performace issues

See original GitHub issue

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • Open the link
  • Try to scroll to see frezzing of hover behavior
  • Slowdown CPU to make sure more clearly (devtoolsPerformanceCPU *x slowdown)

What is expected?

Hovering styles, such as background should be declared using CSS only

What is actually happening?

JS is handled hover behavior, and change a className for each row. It’s creates the performance issues especially for cases with grouped rows (eg rowSpan)

Environment Info
antd > 4.17.0
React 18.1
System mac OS
Browser Chrome 100

Hi 👋 This is actually clone of https://github.com/ant-design/ant-design/issues/35395 issue, it looks like the problem is still there, so i’m trying again Is there are any side effect except changing a background that forces using JS to handle hover? PS Maybe give an opportunity to turn-off hover behavior complete for performance sensitive cases

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
alienzhangywcommented, May 11, 2022

Reference:antd表格性能差的解决方案 Use custom cell render to remove hover events:

// 注意TdCell要提到DataTable作用域外声明
const TdCell = (props: any) => {
  // onMouseEnter, onMouseLeave在数据量多的时候,会严重阻塞表格单元格渲染,严重影响性能
  const { onMouseEnter, onMouseLeave, ...restProps } = props;
  return <td {...restProps} />;
};

const DataTable: React.FC<tableType> = (props) => {
  const { columns,dataSource } = props;
  return <Table 
          columns={columns} 
          dataSource={dataSource} 
          components={{
              body: { cell: TdCell },
            }} 
          />
  );
};

export default DataTable;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Slow response when the HTML table is big - Stack Overflow
The first thing that is slowing your loop down is .insertRow() . You're doing this at the top of your loop and then...
Read more >
A Guide To Hover And Pointer Media Queries
Media Query Hover: Detecting a Pointer #. The hover media query allows us to detect the user's primary input mechanism can hover over...
Read more >
Element: mouseenter event - Web APIs | MDN
With deep hierarchies, the number of mouseover events sent can be quite huge and cause significant performance problems.
Read more >
Moving the mouse: mouseover/out, mouseenter/leave
The mouseover event occurs when a mouse pointer comes over an element, and mouseout – when it leaves. These events are special, because...
Read more >
Popovers · Bootstrap v5.0
For disabled popover triggers, you may also prefer data-bs-trigger="hover focus" so that the popover appears as immediate visual feedback to your users as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found