Sitelet https://web.archive.org/web/20200906092112/https://github.com/mui-org/material-ui/issues/22001
Skip to content
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

Open
guoyunhe opened this issue Jul 30, 2020 · 8 comments
Open

[BottomNavigation] Link docs #22001

guoyunhe opened this issue Jul 30, 2020 · 8 comments

Comments

@guoyunhe
Copy link

@guoyunhe guoyunhe commented Jul 30, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

In my app, I use nextjs links for navigation items. But BottomNavigationItem doesn't support Link (Next.js)

Examples 🌈

Motivation 🔦

@support
Copy link

@support support bot commented Jul 30, 2020

👋 Thanks for using Material-UI!

We use GitHub issues exclusively as a bug and feature requests tracker, however,
this issue appears to be a support request.

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.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

@support support bot closed this Jul 30, 2020
@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jul 30, 2020 •

@guoyunhe
Copy link
Author

@guoyunhe guoyunhe commented Jul 30, 2020

See https://material-ui.com/guides/composition/#routing-libraries, same approach

@oliviertassinari I tried but it doesn't work for BottomNavigationItem. It doesn't have a prop component.

@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jul 30, 2020

@guoyunhe Look closer :)

@guoyunhe
Copy link
Author

@guoyunhe guoyunhe commented Jul 30, 2020

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.

@support support bot reopened this Jul 30, 2020
@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Jul 30, 2020 •

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 should be able to 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

@oliviertassinari oliviertassinari changed the title BottomNavigation link support [BottomNavigation] Link docs Jul 30, 2020
@guoyunhe
Copy link
Author

@guoyunhe guoyunhe commented Jul 30, 2020

I actually want to add links to BottomNavigationAction items.

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 component, VS Code doesn't give prop hints as when typing it on other components, like Button, IconButton. So it makes me think that BottomNavigationAction doesn't support component prop. I don't know why this happen and how to fix it.

It will be more clear if here is an example on https://material-ui.com/components/bottom-navigation/ because most navigations are URL based.

@guoyunhe
Copy link
Author

@guoyunhe guoyunhe commented Jul 30, 2020 •

TypeScript component prop hints works for:

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 ExtendButtonBase and give hints of props.

I am using TypeScript 3.9.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.