|
1 | | -# react-native-bidirectional-infinite-scroll |
| 1 | +# 📜 react-native-bidirectional-infinite-scroll |
2 | 2 |
|
3 | | -Birectional infinite scroll for react-native |
| 3 | +[](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/blob/main/LICENSE) |
| 4 | +[](https://reactnative.dev/) |
4 | 5 |
|
5 | | -## Installation |
| 6 | +Birectional infinite scroll for react-native, with **smooth scrolling**. |
| 7 | + |
| 8 | +**[** Built with ♥ at [Stream](https://getstream.io/) **]** |
| 9 | + |
| 10 | + |
| 11 | +<table> |
| 12 | + <tr> |
| 13 | + <td align='center' width="33%"><img src='https://user-images.githubusercontent.com/11586388/108675127-a5545680-74e6-11eb-89f9-b617b5ce6cc6.gif'/></td> |
| 14 | + <td align='center' width="33%"><img src='https://user-images.githubusercontent.com/11586388/108675105-9ff70c00-74e6-11eb-8abf-7c07b79338e2.gif'/></td> |
| 15 | + </tr> |
| 16 | + <tr></tr> |
| 17 | + <tr> |
| 18 | + <td align='center'> |
| 19 | + <strong>iOS</strong> |
| 20 | + </td> |
| 21 | + <td align='center'> |
| 22 | + <strong>Android</strong> |
| 23 | + </td> |
| 24 | + </tr> |
| 25 | +</table> |
| 26 | + |
| 27 | +## 🛠 Installation |
6 | 28 |
|
7 | 29 | ```sh |
8 | | -npm install react-native-bidirectional-infinite-scroll |
| 30 | +yarn add react-native-bidirectional-infinite-scroll @stream-io/flat-list-mvcp |
9 | 31 | ``` |
10 | 32 |
|
11 | | -## Usage |
| 33 | +## 🔮 Usage |
12 | 34 |
|
13 | | -```js |
14 | | -import BidirectionalInfiniteScroll from "react-native-bidirectional-infinite-scroll"; |
| 35 | +Please check the [example app](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/tree/main/example) for working demo. |
15 | 36 |
|
16 | | -// ... |
| 37 | +```jsx |
| 38 | +import { FlatList } from "react-native-bidirectional-infinite-scroll"; |
| 39 | + |
| 40 | +<FlatList |
| 41 | + data={numbers} |
| 42 | + renderItem={ListItem} |
| 43 | + keyExtractor={(item) => item.toString()} |
| 44 | + onStartReached={onStartReached} // required, should return a promise |
| 45 | + onEndReached={onEndReached} // required, should return a promise |
| 46 | + showDefaultLoadingIndicators={true} // optional |
| 47 | + onStartReachedThreshold={10} // optional |
| 48 | + onEndReachedThreshold={10} // optional |
| 49 | + activityIndicatorColor={'black'} // optional |
| 50 | + HeaderLoadingIndicator={() => { /** Your loading indicator */ }} // optional |
| 51 | + FooterLoadingIndicator={() => { /** Your loading indicator */ }} // optional |
| 52 | + // You can use any other prop on react-native's FlatList |
| 53 | +/> |
17 | 54 |
|
18 | | -const result = await BidirectionalInfiniteScroll.multiply(3, 7); |
19 | 55 | ``` |
20 | 56 |
|
21 | | -## Contributing |
| 57 | +**Note**: |
| 58 | +- `onEndReached` and `onStartReached` only get called once, per content length. |
| 59 | +- `onEndReached` and `onStartReached` must return a promise. |
| 60 | +- `maintainVisibleContentPosition` is fixed, and can't be modified through props. |
| 61 | +- doesn't accept `ListFooterComponent` via prop, since it is occupied by `FooterLoadingIndicator` |
| 62 | + |
| 63 | + |
| 64 | +## ✍ Contributing |
22 | 65 |
|
23 | 66 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. |
24 | 67 |
|
25 | | -## License |
| 68 | +## 🎗 License |
26 | 69 |
|
27 | 70 | MIT |
0 commit comments