Skip to content

Commit 0c7f425

Browse files
doomsowermarcocesarato
authored andcommitted
feat: custom scroll view component
1 parent 4f3c3cb commit 0c7f425

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

docs/docs/props.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ Removes the wrapping view component that is added by BigList.
6161
Using `controlItemRender` will add more arguments to `renderItem`.
6262

6363
```ts
64-
renderItem({ item: unknown, index: number, section: number, key: string, style: object });
64+
renderItem({
65+
item: unknown,
66+
index: number,
67+
section: number,
68+
key: string,
69+
style: object,
70+
});
6571
```
6672

6773
:::note
@@ -213,6 +219,14 @@ Wrap the entire list into an accessory component.
213219
| -------- | -------- |
214220
| function | No |
215221

222+
### `ScrollViewComponent`
223+
224+
Custom component to use instead of react-native's `ScrollView` (e.g. `ScrollView` from `react-native-gesture-handler`)
225+
226+
| Type | Required | Default |
227+
| --------- | -------- | --------------------------- |
228+
| component | No | react-native's `ScrollView` |
229+
216230
### `renderAccessory`
217231

218232
```ts

lib/BigList.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ class BigList extends PureComponent {
953953
hideMarginalsOnEmpty,
954954
hideFooterOnEmpty,
955955
hideHeaderOnEmpty,
956+
ScrollViewComponent,
956957
...props
957958
} = this.props;
958959

@@ -1006,7 +1007,9 @@ class BigList extends PureComponent {
10061007
);
10071008

10081009
const scrollView = wrapper(
1009-
<ScrollView {...scrollViewProps}>{this.renderItems()}</ScrollView>,
1010+
<ScrollViewComponent {...scrollViewProps}>
1011+
{this.renderItems()}
1012+
</ScrollViewComponent>,
10101013
);
10111014

10121015
const scrollStyle = mergeViewStyle(
@@ -1125,6 +1128,7 @@ BigList.propTypes = {
11251128
]),
11261129
sections: PropTypes.array,
11271130
stickySectionHeadersEnabled: PropTypes.bool,
1131+
ScrollViewComponent: PropTypes.func,
11281132
};
11291133

11301134
BigList.defaultProps = {
@@ -1168,6 +1172,7 @@ BigList.defaultProps = {
11681172
insetBottom: 0,
11691173
contentInset: { top: 0, right: 0, left: 0, bottom: 0 },
11701174
onEndReachedThreshold: 0,
1175+
ScrollViewComponent: ScrollView,
11711176
};
11721177

11731178
export default BigList;

lib/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ interface BigListProps<ItemT>
7777
sections?: ItemT[][] | null | undefined;
7878
stickySectionHeadersEnabled?: boolean;
7979
children?: null | undefined;
80+
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
8081
}
8182
export default class BigList<ItemT = any> extends PureComponent<
8283
BigListProps<ItemT>

0 commit comments

Comments
 (0)