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
Copy file name to clipboardExpand all lines: README.md
+40-6Lines changed: 40 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ added. An infinite-scroll that actually works and super-simple to integrate!
38
38
</p>
39
39
}
40
40
// below props only if you need pull down functionality
41
-
refreshFunction={this.refresh}
41
+
refreshFunction={refresh}
42
42
pullDownToRefresh
43
43
pullDownToRefreshThreshold={50}
44
44
pullDownToRefreshContent={
@@ -66,15 +66,15 @@ added. An infinite-scroll that actually works and super-simple to integrate!
66
66
>
67
67
{/*Put the scroll bar always on the bottom*/}
68
68
<InfiniteScroll
69
-
dataLength={this.state.items.length}
70
-
next={this.fetchMoreData}
69
+
dataLength={items.length}
70
+
next={fetchMoreData}
71
71
style={{ display:'flex', flexDirection:'column-reverse' }} //To put endMessage and loader to the top.
72
-
inverse={true}//
72
+
inverse={true}
73
73
hasMore={true}
74
74
loader={<h4>Loading...</h4>}
75
75
scrollableTarget="scrollableDiv"
76
76
>
77
-
{this.state.items.map((_, index) => (
77
+
{items.map((_, index) => (
78
78
<div style={style} key={index}>
79
79
div - #{index}
80
80
</div>
@@ -89,6 +89,40 @@ The `InfiniteScroll` component can be used in three ways.
89
89
- If your **scrollable** content is being rendered within a parent element that is already providing overflow scrollbars, you can set the `scrollableTarget` prop to reference the DOM element and use it's scrollbars for fetching more data.
90
90
- Without setting either the `height` or `scrollableTarget` props, the scroll will happen at `document.body` like _Facebook's_ timeline scroll.
91
91
92
+
## What's new in v7
93
+
94
+
### IntersectionObserver-based triggering
95
+
96
+
`next()` is now triggered by an `IntersectionObserver` watching an invisible sentinel element at the bottom of the list (top for `inverse` mode), rather than a scroll event listener. This means:
97
+
98
+
- The threshold is checked once when the sentinel enters the viewport, not on every scroll tick.
99
+
- No missed triggers when content loads fast enough to skip the threshold.
100
+
- Better performance — no work done while the user is scrolling through content that is far from the threshold.
101
+
102
+
### Zero runtime dependencies
103
+
104
+
`throttle-debounce` has been removed. The package now ships with **zero runtime dependencies**. The `onScroll` callback receives every scroll event directly without throttling.
The component is now a React function component. The public prop API is unchanged — no migration needed.
123
+
124
+
---
125
+
92
126
## docs version wise
93
127
94
128
[3.0.2](docs/README-3.0.2.md)
@@ -114,7 +148,7 @@ The `InfiniteScroll` component can be used in three ways.
114
148
|**dataLength**| number | set the length of the data.This will unlock the subsequent calls to next. |
115
149
|**loader**| node | you can send a loader component to show while the component waits for the next load of data. e.g. `<h3>Loading...</h3>` or any fancy loader element |
116
150
|**scrollThreshold**| number | string | A threshold value defining when `InfiniteScroll` will call `next`. Default value is `0.8`. It means the `next` will be called when user comes below 80% of the total height. If you pass threshold in pixels (`scrollThreshold="200px"`), `next` will be called once you scroll at least (100% - scrollThreshold) pixels down. |
117
-
|**onScroll**| function | a function that will listen to the scroll event on the scrolling container. Note that the scroll event is throttled, so you may not receive as many events as you would expect.|
151
+
|**onScroll**| function | a function that will listen to the scroll event on the scrolling container. |
118
152
|**endMessage**| node | this message is shown to the user when he has seen all the records which means he's at the bottom and `hasMore` is `false`|
119
153
|**className**| string | add any custom class you want |
120
154
|**style**| object | any style which you want to override |
0 commit comments