Skip to content

Commit

Permalink
Allow providing an external scrollview. (#502)
Browse files Browse the repository at this point in the history
* patch: allow providing external scrollview to recyclerlistview

* docs: added ExternalScrollViewComponent to docs

* docs: updated changelog

* refactor: updated the prop name to renderScrollComponent

* refactor: addressing the pr comments

Co-authored-by: Talha Naqvi <naqvitalha@gmail.com>
  • Loading branch information
gorhom and naqvitalha committed Jul 6, 2022
1 parent 73b01b9 commit 5c6fb9a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [1.0.4] - 2022-07-02

- Build fix for Android projects having `kotlinVersion` defined in `build.gradle`.
- Allow providing an external scrollview.
- https://github.com/Shopify/flash-list/pull/502

## [1.0.3] - 2022-07-01

Expand Down
12 changes: 12 additions & 0 deletions documentation/docs/fundamentals/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,18 @@ refreshing?: boolean;

Set this true while waiting for new data from a refresh.

### `renderScrollComponent`

```tsx
import type { ScrollViewProps } from "react-native";

renderScrollComponent?:
| React.ComponentType<ScrollViewProps>
| React.FC<ScrollViewProps>;
```

Rendered as the main scrollview.

### `viewabilityConfig`

```tsx
Expand Down
4 changes: 4 additions & 0 deletions src/FlashList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class FlashList<T> extends React.PureComponent<
initialScrollIndex,
style,
contentContainerStyle,
renderScrollComponent,
...restProps
} = this.props;

Expand Down Expand Up @@ -355,6 +356,9 @@ class FlashList<T> extends React.PureComponent<
windowCorrectionConfig={this.getUpdatedWindowCorrectionConfig()}
itemAnimator={this.itemAnimator}
suppressBoundedSizeException
externalScrollView={
renderScrollComponent as RecyclerListViewProps["externalScrollView"]
}
/>
</StickyHeaderContainer>
);
Expand Down
8 changes: 8 additions & 0 deletions src/FlashListProps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type React from "react";
import {
StyleProp,
ScrollViewProps,
Expand Down Expand Up @@ -137,6 +138,13 @@ export interface FlashListProps<TItem> extends ScrollViewProps {
*/
ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;

/**
* Rendered as the main scrollview.
*/
renderScrollComponent?:
| React.ComponentType<ScrollViewProps>
| React.FC<ScrollViewProps>;

/**
* You can use `contentContainerStyle` to apply padding that will be applied to the whole content itself.
* For example, you can apply this padding, so that all of your items have leading and trailing space.
Expand Down

0 comments on commit 5c6fb9a

Please sign in to comment.