Skip to content

Commit 7b88a47

Browse files
sssssssssssskelset
authored andcommitted
Workaround nested TabNavigation swipe issue (react-navigation#2733)
* Workaround nested TabNavigation swipe issue * Add prop types
1 parent 817e360 commit 7b88a47

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/views/TabView/TabView.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

33
import React, { PureComponent } from 'react';
4-
import { View, StyleSheet } from 'react-native';
4+
import { View, StyleSheet, Platform } from 'react-native';
55
import { TabViewAnimated, TabViewPagerPan } from 'react-native-tab-view';
66
import type { Layout } from 'react-native-tab-view/src/TabViewTypeDefinitions';
77
import SceneView from '../SceneView';
@@ -20,6 +20,7 @@ export type TabViewConfig = {
2020
tabBarComponent?: ReactClass<*>,
2121
tabBarPosition?: 'top' | 'bottom',
2222
tabBarOptions?: {},
23+
initialLayout?: { width: number, height: number },
2324
swipeEnabled?: boolean,
2425
animationEnabled?: boolean,
2526
lazy?: boolean,
@@ -37,6 +38,7 @@ type Props = {
3738
tabBarComponent?: ReactClass<*>,
3839
tabBarPosition?: 'top' | 'bottom',
3940
tabBarOptions?: {},
41+
initialLayout?: { width: number, height: number },
4042
swipeEnabled?: boolean,
4143
animationEnabled?: boolean,
4244
lazy?: boolean,
@@ -206,6 +208,9 @@ class TabView extends PureComponent<void, Props, void> {
206208
screenProps: this.props.screenProps,
207209
style: styles.container,
208210
};
211+
if (Platform.OS === 'android') {
212+
props.initialLayout = { width: 1, height: 0 };
213+
}
209214

210215
return <TabViewAnimated {...props} />;
211216
}

0 commit comments

Comments
 (0)