You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: if we aren't loading, if the collection has changed, and the height is the same, we should load more
67
-
// if we aren't loading, if the collection is the same, and the height is the same, we are either in a case where we are still processing
68
-
// the collection and thus don't want to trigger a load or we had items preloaded and need to load more. That means comparing collection to lastCollection is
69
-
// insufficient
70
-
// might need to wait for height to change?
71
-
// TODO: This doesn't quite work if we dont set a rowHeight in the ListLayout, this is because when
72
-
// Will also need to test against a case where there are sections being loaded and/or estimated height
73
-
// Ideally this layoutEffect would trigger after the collection updates AND the item size has settled
74
-
// Previously, Virtualizer passed state from useVirtualizerState into this hook so that we could get a rerender and trigger this effect
75
-
// as well as compare previous/last sizes
76
-
letshouldLoadMore=onLoadMore
77
-
&&!isLoading
78
-
// For v3 virtualizer, no collection will be provided to this hook so skip this check. Otherwise we should stop loadMore
79
-
// calls in RAC if we are waiting for the collection to be updated from a async load call
// let lastElement = ref.current.querySelector('[role="presentation"]>[role="presentation"]:last-child');
92
+
if(lastElement){
93
+
observer.observe(lastElement);
90
94
}
91
95
92
-
// TODO: only update this when isLoading is false? Might need to guard against the case where loading spinners are added/collection is temporarly wiped/
93
-
// loading spinner is removed when loading finishes (this last one we might still need to guard against somehow...). Seems to be ok for now
94
96
lastCollection.current=collection;
97
+
return()=>{
98
+
if(observer){
99
+
observer.disconnect();
100
+
}
101
+
};
95
102
},[isLoading,onLoadMore,props,ref,collection]);
96
103
104
+
97
105
// TODO: maybe this should still just return scroll props?
98
106
// Test against case where the ref isn't defined when this is called
99
107
// Think this was a problem when trying to attach to the scrollable body of the table in OnLoadMoreTableBodyScroll
0 commit comments