What's the new bound effect in v10 useDrag? #473
Replies: 1 comment 3 replies
-
This is a bit of a shot in the dark as it's been a long time, but trying to gather my thoughts. This is v7: https://github.com/pmndrs/use-gesture/blob/v7/src/Controller.ts This is v10 (highlighting the So v10 rebinds the handlers on every render. I believe this has some collateral functional benefits (besides from a cleaner codebase, but I can't recall exactly what), and the performance penalty is negligible (essentially binding is adding / removing listeners and some string manipulations that aren't really expensive). Let me know if you experience a performance downgrade between the two versions, I'll be happy to have a look (but the only way you could actually see it is by performing a state update on every drag event frame for example, which is in any case not recommended!). |
Beta Was this translation helpful? Give feedback.
-
If I have useDrag's bind hooks attached to a div and click-and-hold on it, with @use-gesture/[email protected] code profiler shows
whereas in otherwise identical code but using [email protected] the code profiler shows
and nothing fires. I looked through the change logs, but couldn't find anything about the bind function and memoization changing. What is this new effect doing? (and what was previously memoized that isn't anymore?)
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions