-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bottom Tab with expo-router 3 #4346
Comments
Found out the above does not work because it removes the header of the containing root stack! |
@silencer07 Did you find a workaround? |
@Shadic78 unfortunately no. I just used the expo tab for my pet project. If you can call this a workaround basically I did this: https://callstack.github.io/react-native-paper/docs/guides/theming-with-react-navigation/
Then on your root
|
Not strictly the same issue but this might help some peeps landing here |
I tried to fix the Props of
I hope this will help: import {
createNavigatorFactory,
DefaultNavigatorOptions,
NavigatorTypeBagBase,
ParamListBase,
StaticConfig,
TabActionHelpers,
TabNavigationState,
TabRouter,
TabRouterOptions,
TypedNavigator,
useNavigationBuilder,
} from "@react-navigation/native";
import {
MaterialBottomTabNavigationEventMap,
MaterialBottomTabNavigationOptions,
MaterialBottomTabView,
} from "react-native-paper/react-navigation";
import { BottomNavigation } from "react-native-paper";
import { withLayoutContext } from "expo-router";
type MaterialBottomTabNavigationConfig = Partial<
Omit<
React.ComponentProps<typeof BottomNavigation>,
| "navigationState"
| "onIndexChange"
| "onTabPress"
| "onTabLongPress"
| "renderScene"
| "renderLabel"
| "renderIcon"
| "getAccessibilityLabel"
| "getBadge"
| "getColor"
| "getLabelText"
| "getTestID"
| "getLazy"
>
>;
export type MaterialBottomTabNavigatorProps = DefaultNavigatorOptions<
ParamListBase,
undefined,
TabNavigationState<ParamListBase>,
MaterialBottomTabNavigationOptions,
MaterialBottomTabNavigationEventMap,
typeof MaterialBottomTabView
> &
TabRouterOptions &
MaterialBottomTabNavigationConfig;
function MaterialBottomTabNavigator({
id,
initialRouteName,
backBehavior,
children,
screenListeners,
screenOptions,
...rest
}: MaterialBottomTabNavigatorProps) {
const { state, descriptors, navigation, NavigationContent } =
useNavigationBuilder<
TabNavigationState<ParamListBase>,
TabRouterOptions,
TabActionHelpers<ParamListBase>,
MaterialBottomTabNavigationOptions,
MaterialBottomTabNavigationEventMap
>(TabRouter, {
id,
initialRouteName,
backBehavior,
children,
screenListeners,
screenOptions,
});
return (
<NavigationContent>
<MaterialBottomTabView
{...rest}
state={state}
navigation={navigation}
descriptors={descriptors}
/>
</NavigationContent>
);
}
function createMaterialBottomTabs<
const ParamList extends ParamListBase,
const NavigatorID extends string | undefined,
const TypeBag extends NavigatorTypeBagBase = {
ParamList: ParamList;
NavigatorID: NavigatorID;
State: TabNavigationState<ParamList>;
ScreenOptions: MaterialBottomTabNavigationOptions;
EventMap: MaterialBottomTabNavigationEventMap;
NavigationList: {
[RouteName in keyof ParamList]: MaterialBottomTabNavigatorProps;
};
Navigator: typeof MaterialBottomTabNavigator;
},
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>
>(config?: Config): TypedNavigator<TypeBag, Config> {
return createNavigatorFactory(MaterialBottomTabNavigator)(config);
}
const { Navigator } = createMaterialBottomTabs();
const MaterialBottomTabs = withLayoutContext<
MaterialBottomTabNavigationOptions,
typeof Navigator,
TabNavigationState<ParamListBase>,
MaterialBottomTabNavigationEventMap
>(Navigator);
export default MaterialBottomTabs; |
See: #4496 (comment) |
Scouring from net I was able to have expo-router use react-native-paper bottom tabs. However
screenOptions
andtabBarIcon
is having error in typescript.What is the proper way of integrating expo-router to react-native-paper's bottom tab without having to resolve to using any on
screenOptions
and manually typing thetabBarIcon
optionThe text was updated successfully, but these errors were encountered: