trigger icon indicating copy to clipboard operation
trigger copied to clipboard

Adding null check before clearing mouseDownTimeout

Open nzayatz14 opened this issue 4 years ago • 2 comments

Hello,

I was recently doing some performance testing on a virtual table component I had written. With rows constantly unmounting & remounting, I wanted to make sure the scroll was still smooth with tooltips (rc-tooltips to be exact).

During my tests, I noticed that a significant amount of my table cells needed to clear a timeout upon unmounting of the row, this caused lag in my scrolling.

Screen Shot 2020-09-25 at 3 59 39 PM

I found the call was made by rc-trigger in it's componentWillUnmount function. I added a simple null-check before the clearTimeout function and it significantly improved my scrolling performance.

I also noticed that the other timer, this.delayTimer, has its own function that handles this case -> this.clearDelayTimer() and was wondering why this.mouseDownTimeout did not have something similar.

Thanks! Nick

nzayatz14 avatar Sep 25 '20 20:09 nzayatz14

Codecov Report

Merging #201 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #201   +/-   ##
=======================================
  Coverage   88.22%   88.22%           
=======================================
  Files          10       10           
  Lines         484      484           
  Branches      121      122    +1     
=======================================
  Hits          427      427           
  Misses         57       57           
Impacted Files Coverage Δ
src/index.tsx 83.78% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b8b8cb2...67c7afc. Read the comment docs.

codecov[bot] avatar Sep 25 '20 20:09 codecov[bot]

I was also running into perf issue caused by the same code when unmounting 10k+ rc-tooltip at the same time. I made a PR that does this and also clears the pointer itself after executing, which potentially gives even more performance gain:

https://github.com/react-component/trigger/pull/278

shc023 avatar Jul 31 '21 00:07 shc023