React exhaustive dependencies rule flags dependency in Infinite Scroll example #959
Unanswered
DemienDrost
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the React Example: Infinite Scroll (GitHub), there's an example how to fetch from the server while the client is running out of item to show. In the dependency array of the
useEffect
responsible for fetching more data, there's a function call torowVirtualizer.getVirtualItems()
.My linter (Biome) has a rule for
correctness/useExhaustiveDependencies
, which flags that dependency and suggests it should berowVirtualizer.getVirtualItems
rather thanrowVirtualizer.getVirtualItems()
. In most cases that would make sense, however here, it's the function's output on which we want to trigger an update.Since the
getVirtualItems
function is memoized in Virtual Core, I suggest the following changes to accommodate this (possibly inappropriate) linter flag, or to at least start discussing this.virtual/examples/react/infinite-scroll/src/main.tsx:55
I did not feel opening a bug for this was appropriate, however I think a discussion about this will be valuable.
Beta Was this translation helpful? Give feedback.
All reactions