Skip to content

Commit b491534

Browse files
committed
Update Scroll ref
1 parent 1f77201 commit b491534

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

apps/common-app/src/components/scrollview/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import React, { useState } from 'react';
1+
import React, { useRef, useState } from 'react';
22
import { Text, StyleSheet, View } from 'react-native';
3-
import { ScrollView, RefreshControl } from 'react-native-gesture-handler';
3+
import {
4+
ScrollView,
5+
RefreshControl,
6+
GHScrollViewRef,
7+
} from 'react-native-gesture-handler';
48

59
const DATA = Array.from({ length: 20 }, (_, i) => ({
610
id: i.toString(),
@@ -16,8 +20,11 @@ const Item = ({ title }: { title: string }) => (
1620
export default function ScrollViewExample() {
1721
const [refreshing, setRefreshing] = useState(false);
1822

23+
const ref = useRef<GHScrollViewRef>(null);
24+
1925
const onRefresh = () => {
2026
setRefreshing(true);
27+
console.log(ref.current);
2128
setTimeout(() => {
2229
setRefreshing(false);
2330
}, 1500);
@@ -26,6 +33,7 @@ export default function ScrollViewExample() {
2633
return (
2734
<ScrollView
2835
contentContainerStyle={styles.container}
36+
ref={ref}
2937
refreshControl={
3038
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
3139
}>

packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const GHScrollView = createNativeWrapper<PropsWithChildren<RNScrollViewProps>>(
4848
DetectorType.Intercepting
4949
);
5050

51-
type ImperativeScrollViewRef = ComponentWrapperRef<RNScrollViewProps> | null;
51+
export type ImperativeScrollViewRef =
52+
ComponentWrapperRef<RNScrollViewProps> | null;
5253

5354
export const ScrollView = (
5455
props: RNScrollViewProps &

packages/react-native-gesture-handler/src/v3/components/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ export {
2121
RefreshControl,
2222
} from './GestureComponents';
2323

24-
export type { ImperativeFlatListRef as GHFlatListRef } from './GestureComponents';
24+
export type {
25+
ImperativeScrollViewRef as GHScrollViewRef,
26+
ImperativeFlatListRef as GHFlatListRef,
27+
} from './GestureComponents';

0 commit comments

Comments
 (0)