trigger
trigger copied to clipboard
Adding null check before clearing mouseDownTimeout
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.
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
Codecov Report
Merging #201 into master will not change coverage. The diff coverage is
100.00%
.
@@ 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.
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