focusHook causes list to become unscrollable
See original GitHub issueBug
There is an issue when using the focusHook
prop on a BottomSheetFlatList. Opening the bottom sheet works fine and the list is scrollable, however when the BottomSheet component re-renders it locks the scrolling of the list.
Some investigation reveals that the re-rendering of BottomSheet
causes ContentWrapper
to also re-render, re-setting maxDeltaY
.
I can see that without focusHook
, the function refreshUIElements
is usually called which sets the maxDeltaY
to 0 and enables scrolling. For some reason this is not happening with focusHook.
Environment info
Both iOS and Android
Library | Version |
---|---|
@gorhom/bottom-sheet | 1.4.1 |
react-native | 0.63.3 |
react-native-reanimated | 2.0.0-alpha.7 |
react-native-gesture-handler | 1.8.0 |
Steps To Reproduce
- Load the example
- Open the bottom sheet and scroll the list
- Tap on a list item which triggers a re-render of the parent component.
- Attempt to scroll the list
Reproducible sample code
import React from 'react';
import BottomSheet, { BottomSheetFlatList, TouchableOpacity } from '@gorhom/bottom-sheet';
import { useFocusEffect, NavigationContainer } from '@react-navigation/native';
import { View, AppRegistry, LogBox } from 'react-native';
import { useState } from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
function Test() {
const [, reRender] = useState(-1);
return (
<SafeAreaProvider>
<BottomSheet snapPoints={[100, 600]}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="List">
{(props) => (
<BottomSheetFlatList
focusHook={useFocusEffect}
data={[...new Array(20)]}
keyExtractor={(_, i) => i.toString()}
renderItem={({ index }) => (
<TouchableOpacity onPress={() => reRender(index)}>
<View
style={{
backgroundColor: 'red',
height: 50,
marginTop: 10
}}
/>
</TouchableOpacity>
)}
/>
)}
</Stack.Screen>
</Stack.Navigator>
</NavigationContainer>
</BottomSheet>
</SafeAreaProvider>
);
}
AppRegistry.registerComponent('Test', () => Test);
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
DSMC2 GEMINI Operation Guide v7.1 - RED camera
Install only the focus hook screw to this mounting point. Damage to the media bay or other components of the camera system caused...
Read more >WeeChat ChangeLog
New features. core: check bar conditions in root bars and on each update of a bar item. core: fully evaluate commands bound to...
Read more >RED RAVEN Operation Guide - Cinequipt
Install only the focus hook or set screw to this mounting point. Damage to the media bay or other components of the camera...
Read more >Scrollview scroll to bottom react native
Props focusHook This needed when bottom sheet used with. ... [0]} will cause the first child to be fixed to the top of...
Read more >The react-native-bottom-sheet from gorhom - Coder Social
Regular views in bottom sheet become unresponsive to gestures after list has been scrolled ... focusHook causes list to become unscrollable ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tankers746 thx!
I have the same problem with a BottomSheetFlatList inside a Navigator inside the Sheet. “Most” of the times (but not always), the FlatList is not scrollable. In my case, it does not make any difference, if I pass on focusHook to the List or not. I am not sure if I experience the same bug or if I maybe made some other mistake using the component…
Andreas
Fixed in V2