question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v3][v4] BottomSheetFlatList (scrollToOffset or scrollToIndex) scrolling to 0 when BottomSheet is collapsed

See original GitHub issue

Bug

https://user-images.githubusercontent.com/3524824/129570109-e3808f8d-00f9-49dc-9812-2f0e37401804.mp4

Environment info

Library Version
@gorhom/bottom-sheet ^4.0.0-alpha.27
react-native ^0.64.2
react-native-reanimated ^2.3.0-alpha.2
react-native-gesture-handler ^1.10.3

Steps To Reproduce

when run ref.current?.scrollToOffset({animated: true, offset: 400}) it should change the y to 400 but this only work when expanded

Describe what you expected to happen:

Change the y position to selected offset.

Reproducible sample code

import BottomSheet, {BottomSheetFlatList} from '@gorhom/bottom-sheet'
import React, {useRef} from 'react'
import {FlatList, View, Text, StyleSheet} from 'react-native'

export default function CaricatureScreen({navigation}: Props) {
  const ref = useRef<FlatList | null>(null)
  const data = ['Test 1', 'Test 2', 'Test 3', 'Test 4', 'Test 5']
  const styles = StyleSheet.create({
    view: {
      height: 200,
      flex: 1,
    },
  }

  setInterval(() => ref.current?.scrollToOffset({animated: true, offset: 400}), 1000)

  return (
    <BottomSheet index={0} snapPoints={[100, '70%']}>
      <BottomSheetFlatList 
        ref={ref} 
        data={data}
        renderItem={({index, item}) => (
          <View style={styles.view}>
            <Text>{item}</Text>
          </View>
        )}
      />
    </BottomSheet>
  )
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
LorandPcommented, Jul 10, 2022

I would also like to know how to scroll to a specific index

1reaction
akinyelecommented, Apr 27, 2022

Was there any solution for this issue. I’m encountering something similar. ref.current.scrollToIndex only works when the bottom sheet is expanded to the final snap point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BottomSheetFlatList ref.current.scrollToIndex not scrolling #414
I seems to be unable to make a BottomSheetFlatList scroll to a specific index with restaurantListRef.current?.scrollToIndex({index}); .
Read more >
Scrollview not scrolling in Android bottomsheet - Stack Overflow
Every time I try to scroll, either the layout in main activity that scroll or the BottomSheet changing state from collapse to expand....
Read more >
Scrollables | React Native Bottom Sheet - GitHub Pages
This library provides a pre-integrated virtualized lists that utilize an internal functionalities with the bottom sheet container to allow smooth panning ...
Read more >
react-native-scroll-bottom-sheet - npm
Cross platform scrollable bottom sheet with virtualization support, running at 60 FPS and fully implemented in JS land.
Read more >
React Native scrollToIndex - Dynamic size item scroll inside ...
In this video tutorial you will learn about React Native scrollToIndex and how to scroll to an item inside a FlatList, ListView, ScrollView, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found