Replies: 1 comment
-
The IntersectionObserver api is async, so tid is more a question of React rendering optimization. If performance is an issue, I'd recommend using the You can use a debounced value to defer/set it after a timeout. (Look up hooks for this) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm not sure if "defer" is the right word here, but essentially, I use this library for a list where each item component relies on this hook. The list can sometimes contain over 100 items. I use the hook to hide content and boost performance by hiding elements that are not in view. However, there's an issue when users quickly scroll down and then back up, causing the hook to trigger multiple times.
I know I could adjust the
rootMargin
, but it's still not ideal for handling rapid scrolling through a large number of items. I could implement another state with a timer to manage this, like so:But this approach would trigger an additional re-render apart from the
useInView
hook. It would be great if this functionality were built into the library. Do we have an option for this currently?Beta Was this translation helpful? Give feedback.
All reactions