Skip to content

Commit 7013370

Browse files
Minishlinkvonovak
authored andcommitted
Set initialLayout in defaultProps on Android (react-navigation#2843)
* Revert "Workaround nested TabNavigation swipe issue (react-navigation#2733)" This reverts commit 7b88a47. * Set initialLayout in defaultProps on Android This reverts the previous PR (react-navigation#2733) and takes into account react-navigation#2385 In order to fix satya164/react-native-tab-view#312 * Don't use window's dimensions
1 parent 7b88a47 commit 7013370

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/views/TabView/TabView.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export type TabViewConfig = {
2020
tabBarComponent?: ReactClass<*>,
2121
tabBarPosition?: 'top' | 'bottom',
2222
tabBarOptions?: {},
23-
initialLayout?: { width: number, height: number },
2423
swipeEnabled?: boolean,
2524
animationEnabled?: boolean,
2625
lazy?: boolean,
@@ -38,7 +37,6 @@ type Props = {
3837
tabBarComponent?: ReactClass<*>,
3938
tabBarPosition?: 'top' | 'bottom',
4039
tabBarOptions?: {},
41-
initialLayout?: { width: number, height: number },
4240
swipeEnabled?: boolean,
4341
animationEnabled?: boolean,
4442
lazy?: boolean,
@@ -56,7 +54,14 @@ type Props = {
5654
},
5755
};
5856

59-
class TabView extends PureComponent<void, Props, void> {
57+
class TabView extends PureComponent<$Shape<Props>, Props, void> {
58+
static defaultProps = {
59+
// fix for https://github.com/react-native-community/react-native-tab-view/issues/312
60+
initialLayout: Platform.select({
61+
android: { width: 1, height: 0 },
62+
}),
63+
};
64+
6065
props: Props;
6166

6267
_handlePageChanged = (index: number) => {
@@ -208,9 +213,6 @@ class TabView extends PureComponent<void, Props, void> {
208213
screenProps: this.props.screenProps,
209214
style: styles.container,
210215
};
211-
if (Platform.OS === 'android') {
212-
props.initialLayout = { width: 1, height: 0 };
213-
}
214216

215217
return <TabViewAnimated {...props} />;
216218
}

0 commit comments

Comments
 (0)