-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[BottomNavigation] Link docs #22001
Comments
👋 Thanks for using Material-UI! We use GitHub issues exclusively as a bug and feature requests tracker, however, For support, please check out https://material-ui.com/getting-started/support/. Thanks! If you have a question on StackOverflow, you are welcome to link to it here, it might help others. |
See https://material-ui.com/guides/composition/#routing-libraries, same approach |
@oliviertassinari I tried but it doesn't work for |
@guoyunhe Look closer :) |
I did read the entire page, word by word, for three times. But didn't get it. It will be really helpful if here is any working example. |
What do you think about this diff? diff --git a/docs/src/pages/guides/composition/composition.md b/docs/src/pages/guides/composition/composition.md
index 45a2bdc5d..ef24268b8 100644
--- a/docs/src/pages/guides/composition/composition.md
+++ b/docs/src/pages/guides/composition/composition.md
@@ -133,7 +133,7 @@ You can find the details in the [TypeScript guide](/guides/typescript/#usage-of-
The integration with third-party routing libraries is achieved with the `component` prop.
The behavior is identical to the description of the prop above.
Here are a few demos with [react-router-dom](https://github.com/ReactTraining/react-router).
-It covers the Button, Link, and List components, you should be able to apply the same strategy with all the components.
+They cover the Button, Link, and List components. You can apply the same strategy with all the components (BottomNavigation, Card, etc.).
### Button Do you want to work on it? I haven't included Tabs because we will get it covered in #18811 |
I actually want to add links to For example, I have: <BottomNavigation>
<BottomNavigationAction label="Home" icon={<HomeIcon/>} component={ReactRouterLink} to="/" />
<BottomNavigationAction label="Posts" icon={<ListIcon/>} component={ReactRouterLink} to="/posts" />
<BottomNavigationAction label="Profile" icon={<PersonIcon/>} component={ReactRouterLink} to="/profile" />
</BottomNavigation> It is very weird that when I type It will be more clear if here is an example on https://material-ui.com/components/bottom-navigation/ because most navigations are URL based. |
TypeScript declare const BottomNavigation: OverridableComponent<BottomNavigationTypeMap>;
declare const Link: OverridableComponent<LinkTypeMap>;
declare const Divider: OverridableComponent<DividerTypeMap>; not work for: declare const BottomNavigationAction: ExtendButtonBase<BottomNavigationActionTypeMap<
{},
ButtonBaseTypeMap['defaultComponent']
>>;
declare const Tab: ExtendButtonBase<TabTypeMap>;
declare const Fab: ExtendButtonBase<FabTypeMap>;
declare const Button: ExtendButtonBase<ButtonTypeMap>; So I guess TypeScript had some trouble to understand I am using TypeScript 3.9.6. |
I could take a look at this issue. Do I need to be assigned? |
@oliviertassinari I created a component with the following code. I was able to import in the index.js page and it is working. maybe the issue that prevented next Link from working with the Material UI component was fixed. import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import BottomNavigation from "@material-ui/core/BottomNavigation";
import BottomNavigationAction from "@material-ui/core/BottomNavigationAction";
import RestoreIcon from "@material-ui/icons/Restore";
import FavoriteIcon from "@material-ui/icons/Favorite";
import LocationOnIcon from "@material-ui/icons/LocationOn";
import Link from "next/link";
const useStyles = makeStyles({
root: {
width: 500,
},
});
export default function SimpleBottomNavigation() {
const classes = useStyles();
const [value, setValue] = React.useState(0);
return (
<BottomNavigation
value={value}
onChange={(event, newValue) => {
setValue(newValue);
}}
showLabels
className={classes.root}
>
<Link href="/recents" >
<a>
<BottomNavigationAction label="Recents" icon={<RestoreIcon />} />
</a>
</Link >
<Link href="/favorites" >
<a>
<BottomNavigationAction label="Favorites" icon={<FavoriteIcon />} />
</a>
</Link>
<Link href="/nearby" >
<a>
<BottomNavigationAction label="Nearby" icon={<LocationOnIcon />} />
</a>
</Link>
</BottomNavigation>
);
} |
@Maxgit3 As far as I know, we never had any issue here. The only way to move forward I can see is to include all the components that are supported in the docs: #22001 (comment). Do you want to do it? :) |
@oliviertassinari Sure, I will look into it. |
A simple solution:
|
Thanks @topovik - your solution fixed this issue for me and it's working well 😃 |
it works for me but i didn't understand why we are using useRouter instead of Link of nextjs. |
The problem we are facing is that the BottomNavigationAction creates a button element and we want an anchor tag. A link driven by JS on a button is detrimental for SEO |
Thanks for this! This helped me and works with useNavigate too!
|
how to route to the destined page with the tab bar keeping at the bottom? this code would change the entire page |
Summary 💡
In my app, I use nextjs links for navigation items. But
BottomNavigationItem
doesn't supportLink
(Next.js)Examples 🌈
Motivation 🔦
The text was updated successfully, but these errors were encountered: