Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit 3e2386b

Browse files
committed
docs: update README.md
1 parent 2192ce7 commit 3e2386b

File tree

1 file changed

+63
-9
lines changed

1 file changed

+63
-9
lines changed

README.md

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,80 @@
1-
# react-native-scrollview-enhancer
1+
# @sendbird/react-native-scrollview-enhancer
22

3-
ScrollView enhancer
3+
A utility package that enables the use of `onStartReached` and `maintainVisibleContentPosition` features in ScrollView components in react-native versions prior to 0.72.
44

55
## Installation
66

77
```sh
8-
npm install react-native-scrollview-enhancer
8+
npm install @sendbird/react-native-scrollview-enhancer
99
```
1010

1111
## Usage
1212

13-
```js
14-
import { ScrollViewEnhancerView } from "react-native-scrollview-enhancer";
13+
You can use a scroll view components with `onStartReached` and `maintainVisibleContentPosition` applied as follows.
1514

16-
// ...
15+
```tsx
16+
import { FlatList, ScrollView, SectionList } from '@sendbird/react-native-scrollview-enhancer';
1717

18-
<ScrollViewEnhancerView color="tomato" />
18+
const App = () => {
19+
return (
20+
<FlatList
21+
inverted
22+
data={messages}
23+
renderItem={renderMessageItem}
24+
onEndReached={onEndReached}
25+
onStartReached={onStartReached}
26+
/>
27+
);
28+
};
1929
```
2030

21-
## Contributing
31+
## Customization
2232

23-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
33+
### maintainVisibleContentPosition
34+
35+
The `maintainVisibleContentPosition` feature can be used by wrapping the ScrollView component (`ScrollView`, `FlatList`, `SectionList`, `VirtualizedList`) that you want to use with the `ScrollViewEnhancerView` component.
36+
37+
```tsx
38+
import { ScrollView } from 'react-native';
39+
import { ScrollViewEnhancerView } from '@sendbird/react-native-scrollview-enhancer';
40+
41+
const App = () => {
42+
return (
43+
<ScrollViewEnhancerView>
44+
<ScrollView />
45+
</ScrollViewEnhancerView>
46+
);
47+
};
48+
```
49+
50+
### onStartReached
51+
52+
This package provides a `useBidirectional` hook that adds `onStartReached` to the `ScrollView`.
53+
54+
```tsx
55+
import { View, FlatList } from 'react-native';
56+
import { useBiDirectional } from '@sendbird/react-native-scrollview-enhancer';
57+
58+
const App = () => {
59+
const { renderScrollView } = useBiDirectional(FlatList, props, ref);
60+
return <View>{renderScrollView()}</View>;
61+
};
62+
```
63+
64+
### Utility functions
65+
66+
This package provides the following utility functions to make it easier to use:
67+
68+
- enhanceScrollView: adds `maintainVisibleContentPosition` feature to the ScrollView component
69+
- enhanceScrollViewWithBidirectional: adds `maintainVisibleContentPosition` and `onStartReached` features to the ScrollView component
70+
71+
```tsx
72+
import { ScrollView, FlatList } from 'react-native';
73+
import { enhanceScrollView, enhanceScrollViewWithBidirectional } from '@sendbird/react-native-scrollview-enhancer';
74+
75+
const EnhancedScrollView = enhanceScrollView(ScrollView);
76+
const BiDirectionalFlatList = enhanceScrollViewWithBidirectional(FlatList);
77+
```
2478

2579
## License
2680

0 commit comments

Comments
 (0)