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: docs/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: Introduction
9
9
10
10
## Easy to use
11
11
12
-
To make `InfiniteScroll` work, you just need to tell it whether your application is loading and are there more data to load, then create your `Item` component with `React.forwardRef`and an array with a specific type. Finally, pass a function which should be called when the last item displayed in the viewport.
12
+
To make `InfiniteScroll` work, you just need to tell it whether your application is loading, whether there are more data and the function you want to call when it reach bottom
@@ -46,24 +39,6 @@ declare function InfiniteScroll<T, P extends HTMLElement>({
46
39
47
40
Used to determine whether there are more items to display. If the last item is displayed in the viewport and `hasMore` is `true`, then `InfiniteScroll` will call `next()`.
48
41
49
-
### `Item`
50
-
51
-
A React component with `React.forwardedRef` or a string like `li`. `InfiniteScroll` will pass a callback function to the last item's ref in order to determine whether the last item is displayed in the viewport.
52
-
53
-
### `itemData`
54
-
55
-
An array of objects. The object in this array has 2 properties called `key` and `props`.
56
-
57
-
#### `key`
58
-
59
-
Since `InfiniteScroll` will use `map()` to generate the `Item` component, it needs a key to help React distinguish between components. If the items in `InfiniteScroll` will be deleted or moved, then you should specify a key.
60
-
61
-
If `key` is not specified, then `InfiniteScroll` will use the index as a key.
62
-
63
-
#### `props`
64
-
65
-
The properties that will be passed to `Item` component. Its type should be the same as `Item`'s props.
66
-
67
42
### `next`
68
43
69
44
If `isLoading` is `false` and `hasMore` is `true`, then this function will be called when this last item is displayed in the viewport.
@@ -97,3 +72,7 @@ Set this property to `true` means that `InfiniteScroll` will call `next` when th
97
72
If your `next` function prepend the new data to the previous data, the first item will always show up on the top. This will cause `InfiniteScroll` continuously call `next`. Make sure write some code to prevent this circumstance or use [`useScrollToOld`](./useScrollToOld.md);
98
73
99
74
:::
75
+
76
+
### `children`
77
+
78
+
`InfiniteScroll` will pass ref to your children, if your children is a custom component, make sure using `React.forwardRef` to forward ref to its container.
The 5 properties in the above example are required. For more information about these properties, please see the [API Reference page.](api/InfiniteScroll.md)
54
+
## Create your `Item` component
55
+
56
+
You can also use a custom component in `InfiniteScroll`, but you should make sure the component pass `ref` to its container correctly.
57
+
58
+
```tsx
59
+
exportinterfaceItemProps {
60
+
data:any;
61
+
}
62
+
63
+
function Item(props:ItemProps, ref:React.FowardedRef<HTMLLIElement>) {
0 commit comments