Skip to content

Commit

Permalink
feat: custom scroll view component
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower authored and marcocesarato committed Jan 15, 2022
1 parent 4f3c3cb commit 0c7f425
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
16 changes: 15 additions & 1 deletion docs/docs/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ Removes the wrapping view component that is added by BigList.
Using `controlItemRender` will add more arguments to `renderItem`.

```ts
renderItem({ item: unknown, index: number, section: number, key: string, style: object });
renderItem({
item: unknown,
index: number,
section: number,
key: string,
style: object,
});
```

:::note
Expand Down Expand Up @@ -213,6 +219,14 @@ Wrap the entire list into an accessory component.
| -------- | -------- |
| function | No |

### `ScrollViewComponent`

Custom component to use instead of react-native's `ScrollView` (e.g. `ScrollView` from `react-native-gesture-handler`)

| Type | Required | Default |
| --------- | -------- | --------------------------- |
| component | No | react-native's `ScrollView` |

### `renderAccessory`

```ts
Expand Down
7 changes: 6 additions & 1 deletion lib/BigList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ class BigList extends PureComponent {
hideMarginalsOnEmpty,
hideFooterOnEmpty,
hideHeaderOnEmpty,
ScrollViewComponent,
...props
} = this.props;

Expand Down Expand Up @@ -1006,7 +1007,9 @@ class BigList extends PureComponent {
);

const scrollView = wrapper(
<ScrollView {...scrollViewProps}>{this.renderItems()}</ScrollView>,
<ScrollViewComponent {...scrollViewProps}>
{this.renderItems()}
</ScrollViewComponent>,
);

const scrollStyle = mergeViewStyle(
Expand Down Expand Up @@ -1125,6 +1128,7 @@ BigList.propTypes = {
]),
sections: PropTypes.array,
stickySectionHeadersEnabled: PropTypes.bool,
ScrollViewComponent: PropTypes.func,
};

BigList.defaultProps = {
Expand Down Expand Up @@ -1168,6 +1172,7 @@ BigList.defaultProps = {
insetBottom: 0,
contentInset: { top: 0, right: 0, left: 0, bottom: 0 },
onEndReachedThreshold: 0,
ScrollViewComponent: ScrollView,
};

export default BigList;
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface BigListProps<ItemT>
sections?: ItemT[][] | null | undefined;
stickySectionHeadersEnabled?: boolean;
children?: null | undefined;
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
}
export default class BigList<ItemT = any> extends PureComponent<
BigListProps<ItemT>
Expand Down

0 comments on commit 0c7f425

Please sign in to comment.