react-navigation / react-navigation/react-navigation.github.io
Swipeable TabScreen
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 324
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
How can I enable swipe in TabScreen?
I want to change screens when the user swipes on it in (Android and IOS).
Is there any property that I am missing?
<Tab.Navigator
initialRouteName="home"
tabBarOptions={{
keyboardHidesTabBar: true,
}}
tabBar={props => <CustomBottomBar {...props} />}>
<Tab.Screen
name="home"
component={HomeScreen}
options={{
tabBarLabel: 'Abc',
}}
/>
<Tab.Screen
name="splash"
component={SplashScreen}
options={{
tabBarLabel: 'Xyz',
}}
/>
</Tab.Navigator>
function CustomTabBar({ state, descriptors, navigation }) {
return (
<View style={{ flexDirection: 'row' }}>
{state.routes.map((route, index) => {
const { options } = descriptors[route.key];
const label =
options.tabBarLabel !== undefined
? options.tabBarLabel
: options.title !== undefined
? options.title
: route.name;
const isFocused = state.index === index;
const onPress = () => {
const event = navigation.emit({
type: 'tabPress',
target: route.key,
canPreventDefault: true,
});
if (!isFocused && !event.defaultPrevented) {
navigation.navigate(route.name);
}
};
const onLongPress = () => {
navigation.emit({
type: 'tabLongPress',
target: route.key,
});
};
return (
<TouchableOpacity
accessibilityRole="button"
accessibilityStates={isFocused ? ['selected'] : []}
accessibilityLabel={options.tabBarAccessibilityLabel}
testID={options.tabBarTestID}
onPress={onPress}
onLongPress={onLongPress}
style={{ flex: 1 }}
>
<Text style={{ color: isFocused ? '#673ab7' : '#222' }}>
{label}
</Text>
</TouchableOpacity>
);
})}
</View>
);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by checking the Tab.Navigator documentation and existing Android/iOS navigation guidance for swipe-related configuration. Done means clearly documenting whether swipe navigation is supported and, if so, where the required configuration or example belongs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- documentation, mobile-dev
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100