You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The header position is glitchy on Android when switching between tabs. It seems like the scroll offset is not synced properly between the tabs. Please see my code and video of behavior below:
Example behaviour of bug
android-header-glitch.mp4
MyTabView.tsx
exportconstMyTabView: React.FC=()=>{const{ width }=useWindowDimensions();const[index,setIndex]=React.useState(1);const[routes]=React.useState<TabViewRoute[]>([{key: 'tab0',title: 'Tab 0'},{key: 'tab1',title: 'Tab 1'},{key: 'tab2',title: 'Tab 2'},]);// MyCustomFlatList is wrapped with React.memo as described by // https://github.com/satya164/react-native-tab-view#optimization-tipsconstrenderScene=({ route }: {route: TabViewRoute})=>{switch(route.key){case'tab0':
return<MyCustomFlatListindex={0}/>;case'tab1':
return<MyCustomFlatListindex={1}/>;case'tab2':
return<MyCustomFlatListindex={2}/>;default:
returnnull;}};constrenderTabBar=(props: MyCustomProps)=>(<CustomTabBar{...props}currentRoute={routes[index].key}/>);// MyCustomHeader is also wrapped with React.memo like above// it returns a react-native-snap-carousel component// https://www.npmjs.com/package/react-native-snap-carouselconstrenderScrollHeader=()=><MyCustomHeader/>;
return(<CollapsibleHeaderTabViewsceneContainerStyle={styles.sceneContainer}navigationState={{ index, routes }}initialLayout={{ width }}renderScene={renderScene}onIndexChange={setIndex}renderTabBar={renderTabBar}renderScrollHeader={renderScrollHeader}headerHeight={247}/>
);};
MyCustomFlatList.tsx
// exportconstMyCustomFlatList: React.FC<Props>=React.memo(({ index, ...props})=>{constkeyExtractor=(item: MyItem)=>item.id.toString();constrenderItem=({ item }: {item: MyItem})=>{// ... render some components};// Some other logic, eg data fetching, onMomentumScrollBegin, onEndReached...return(<HFlatListindex={index}contentContainerStyle={styles.contentContainer}initialNumToRender={7}data={MY_DATA}onMomentumScrollBegin={onMomentumScrollBegin}onScrollBeginDrag={onMomentumScrollBegin}onEndReached={onEndReached}onEndReachedThreshold={3}keyExtractor={keyExtractor}renderItem={renderItem}/>);},);
Expected behavior
Expect the header to be in sync between tabs. iOS is working perfectly.
Video of my app working as expected
ios-header.mp4
Package versions
React: 17.0.2
React Native: 0.67.3
React-Native-Gesture-Handler: 2.6.0
react-native-reanimated: 2.5.0
react-native-tab-view: 3.1.1
The text was updated successfully, but these errors were encountered:
IB3N
changed the title
Glitchy header offset position on Android - offsets might not be syncing properly?
Glitchy header offset position on Android - offsets might not be syncing properly
Sep 15, 2022
Describe the bug
The header position is glitchy on Android when switching between tabs. It seems like the scroll offset is not synced properly between the tabs. Please see my code and video of behavior below:
Example behaviour of bug
android-header-glitch.mp4
MyTabView.tsx
MyCustomFlatList.tsx
Expected behavior
Expect the header to be in sync between tabs. iOS is working perfectly.
Video of my app working as expected
ios-header.mp4
Package versions
17.0.2
0.67.3
2.6.0
2.5.0
3.1.1
The text was updated successfully, but these errors were encountered: