Skip to content

Commit 304f6f9

Browse files
authored
Add support for onRefresh on scroll views (#926)
1 parent cf94683 commit 304f6f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

packages/core/src/components/SimpleStyleScrollables/SimpleStyleScrollView.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import React from "react";
2-
import { ScrollView } from "react-native";
2+
import { ScrollView, RefreshControl } from "react-native";
33
import type { ScrollViewProps } from "react-native";
44
import useSplitContentContainerStyles from "./useSplitContentContainerStyles";
55

6+
interface Props extends Omit<ScrollViewProps, "contentContainerStyle"> {
7+
onRefresh?: () => void;
8+
refreshing?: boolean;
9+
}
10+
611
/**
712
* A ScrollView wrapper that takes a single `style` prop and internally extracts
813
* the appropriate style keys into the `contentContainerStyle`
914
*/
1015
const SimpleStyleScrollView = React.forwardRef(
1116
(
12-
{
13-
style: styleProp,
14-
...rest
15-
}: Omit<ScrollViewProps, "contentContainerStyle">,
17+
{ style: styleProp, onRefresh, refreshing = false, ...rest }: Props,
1618
ref: React.Ref<ScrollView>
1719
) => {
1820
const { style, contentContainerStyle } =
@@ -23,6 +25,11 @@ const SimpleStyleScrollView = React.forwardRef(
2325
ref={ref}
2426
style={style}
2527
contentContainerStyle={contentContainerStyle}
28+
refreshControl={
29+
onRefresh ? (
30+
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
31+
) : undefined
32+
}
2633
{...rest}
2734
/>
2835
);

0 commit comments

Comments
 (0)