Skip to content

[Material-ui 4] Typescript: component property does not exist on MenuItem #14970

Closed
@sveyret

Description

@sveyret

I am testing mui@next. When I try to create a link (through react-router) on a MenuItem, creating a component as the documentation suggests, I have an error saying that porperty 'component' does not exist on type 'IntrinsicAttributes & { action?: ((actions: ButtonBaseActions) => void) | undefined; buttonRef?: ((instance: any) => void) | RefObject | null | undefined; centerRipple?: boolean | undefined; ... 6 more ...; TouchRippleProps?: Partial<...> | undefined; } & { ...; } & { ...; } & CommonProps<...> & Pick<...>'

This was working correctly with mui < v4.0

Note that it seemed to have already appeared and corrected in alpha.3 (#14786)

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

Code 🕹

const component:
  | React.ExoticComponent<LinkProps>
  | undefined = React.forwardRef<Link, LinkProps>(
  ({ children, ...props }, ref) => (
    <Link {...props} to="/" ref={ref}>
      {children}
    </Link>
  )
);

function displayMenuEntryContent() {
  return (
    <MenuItem component={component}>
      <ListItemText primary="Home" />
    </MenuItem>
  );
}

// Render
return displayMenuEntryContent();

Your Environment 🌎

Tech Version
Material-UI 4.0.0-alpha.4
React 16.8.4
React router 5.0.0
@types/react 16.8.8
TypeScript 3.3.3333

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions