Skip to content

Commit e474363

Browse files
Fix iModel browser skipping pages (#143)
* Don't increment page number while an update is pending * Actually fix skipped page * Fix setState while rendering * rush change
1 parent c1f834a commit e474363

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/imodel-browser-react",
5+
"comment": "Fix iModel browser skipping pages",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@itwin/imodel-browser-react"
10+
}

packages/modules/imodel-browser/src/containers/iModelGrid/IModelGrid.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,12 @@ export const IModelGrid = ({
205205
/>
206206
))}
207207
{fetchMore ? (
208-
<InView>
209-
{({ inView, ref }) => {
208+
<InView
209+
onChange={(inView) => {
210210
inView && fetchStatus !== DataStatus.Fetching && fetchMore();
211+
}}
212+
>
213+
{({ ref }) => {
211214
return <IModelGhostTile ref={ref} />;
212215
}}
213216
</InView>

packages/modules/imodel-browser/src/containers/iModelGrid/useIModelData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ export const useIModelData = ({
7171
}, []);
7272

7373
const fetchMore = React.useCallback(() => {
74-
if (status === DataStatus.Fetching || !morePagesAvailable) {
74+
if (needsUpdate || status === DataStatus.Fetching || !morePagesAvailable) {
7575
return;
7676
}
77-
setPage((prev) => prev + 1);
77+
setPage(page + 1);
7878
setNeedsUpdate(true);
79-
}, [status, morePagesAvailable]);
79+
}, [needsUpdate, status, morePagesAvailable, page]);
8080

8181
React.useEffect(() => {
8282
// start from scratch when any external state changes

0 commit comments

Comments
 (0)