about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-02-22 21:21:17 -0600
committerPaul Frazee <pfrazee@gmail.com>2023-02-22 21:21:17 -0600
commit2db7ad8ef326c582c698d1f7248aae7dc5c2c423 (patch)
treec2ea027490cef4a2e765b2573ac8272fb4f534b8
parentf28334739b107f3e9f7b6ca2670778dba280600d (diff)
downloadvoidsky-2db7ad8ef326c582c698d1f7248aae7dc5c2c423.tar.zst
Fix ref forwarding in web
-rw-r--r--src/view/com/util/Views.web.tsx37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/view/com/util/Views.web.tsx b/src/view/com/util/Views.web.tsx
index c16070b2b..f00d3c072 100644
--- a/src/view/com/util/Views.web.tsx
+++ b/src/view/com/util/Views.web.tsx
@@ -33,10 +33,13 @@ export function CenteredView({
   return <View style={style} {...props} />
 }
 
-export function FlatList<ItemT>({
-  contentContainerStyle,
-  ...props
-}: React.PropsWithChildren<FlatListProps<ItemT>>) {
+export const FlatList = React.forwardRef(function <ItemT>(
+  {
+    contentContainerStyle,
+    ...props
+  }: React.PropsWithChildren<FlatListProps<ItemT>>,
+  ref: React.Ref<RNFlatList>,
+) {
   const theme = useTheme()
   contentContainerStyle = addStyle(
     contentContainerStyle,
@@ -46,13 +49,19 @@ export function FlatList<ItemT>({
     contentContainerStyle,
     theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight,
   )
-  return <RNFlatList contentContainerStyle={contentContainerStyle} {...props} />
-}
+  return (
+    <RNFlatList
+      contentContainerStyle={contentContainerStyle}
+      ref={ref}
+      {...props}
+    />
+  )
+})
 
-export function ScrollView({
-  contentContainerStyle,
-  ...props
-}: React.PropsWithChildren<ScrollViewProps>) {
+export const ScrollView = React.forwardRef(function (
+  {contentContainerStyle, ...props}: React.PropsWithChildren<ScrollViewProps>,
+  ref: React.Ref<RNFlatList>,
+) {
   const theme = useTheme()
   contentContainerStyle = addStyle(
     contentContainerStyle,
@@ -63,9 +72,13 @@ export function ScrollView({
     theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight,
   )
   return (
-    <RNScrollView contentContainerStyle={contentContainerStyle} {...props} />
+    <RNScrollView
+      contentContainerStyle={contentContainerStyle}
+      ref={ref}
+      {...props}
+    />
   )
-}
+})
 
 const styles = StyleSheet.create({
   container: {