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

Bug Report: AppBarNavigation incompatible with Links that don't use the to props #243

Open
pat-encoura opened this issue May 4, 2023 · 0 comments
Assignees

Comments

@pat-encoura
Copy link

Describe the bug
The navigationItems props expects an array of items with a LinkProps objects containing a to field. The problem is that my Link component uses an href prop. Using that in LinkProps produces the following TS error:

Types of property 'LinkProps' are incompatible. Property 'to' is missing in type '{ href: string; }' but required in type '{ to: string; }'.

And my navigationItems array looks like:

  const navigationItems = [
    {
      isActive: ROUTES.INDEX === activeRoute,
      LinkComponent: Link,
      LinkProps: {
        href: ROUTES.INDEX,
      },
      title: 'Home',
    },
  ];

My Link component's href prop is extended directly from @mui/material/Link's LinkProps.

To Reproduce
Pass in a LinkComponent that uses any prop other than to for its href value.

Expected behavior
The AppBarNavigation component should not produce a TS error when a Link component uses a non-to prop. Ideally, it should not be prescriptive about the Link component's API at all (either through leveraging generics, accepting React elements directly w/ props set by the library consumer, or some other method).

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

No branches or pull requests

2 participants