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

Pull Request, which adds component prop to OverrideProps type, breaks MUI behavior #38079

Closed
2 tasks done
e965 opened this issue Jul 20, 2023 · 1 comment
Closed
2 tasks done
Labels
core Infrastructure work going on behind the scenes duplicate This issue or pull request already exists package: material-ui Specific to @mui/material

Comments

@e965
Copy link

e965 commented Jul 20, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

No response

Current behavior 😯

No response

Expected behavior 🤔

No response

Context 🔦

It's about this pull-quest #35924

This PR seems to have broken some of the MUI use cases. Here is my example - we have a Link component in our application. It is a wrapper over Link from MUI, to which Link from react-router-dom is passed as component prop. The code looks like this:

import React from 'react';

import { Link as MuiLink, LinkProps as MuiLinkProps } from '@mui/material';
import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom';

type LinkProps = MuiLinkProps<typeof RouterLink, RouterLinkProps>;

export const Link: React.FC<React.PropsWithChildren<LinkProps>> = ({ children, ...props }) => {
  return (
    <MuiLink component={RouterLink} {...props}>
      {children}
    </MuiLink>
  );
};

In case we needed to make a link button, we just did

import { Button } from '@mui/material';
import { Link } from '../path/to/Link';

<Button component={Link} to="/some-route">Link</Button>

and didn't experience any problems, everything worked. Now this case is not possible due to typescript errors.

Type 'FC<PropsWithChildren<LinkProps>>' is not assignable to type 'ForwardRefExoticComponent<LinkProps & RefAttributes<HTMLAnchorElement>> & FC<PropsWithChildren<LinkProps>>'.ts(2322)|
OverridableComponent.d.ts(42, 7): The expected type comes from property 'component' which is declared here on type 'IntrinsicAttributes & { children?: ReactNode; classes?: Partial<ButtonClasses> | undefined; color?: "inherit" | "primary" | ... 7 more ... | undefined; ... 9 more ...; variant?: "text" | ... 2 more ... | undefined; } & ... 4 more ... & CustomButtonProps<...>'

This is just one case, there are several more similar ones in our application. But the point is that this PR breaks MUI behavior, which always worked fine.

Your environment 🌎

npx @mui/envinfo
  npmPackages:
    @emotion/react:  11.11.1
    @emotion/styled:  11.11.0
    @mui/base:  5.0.0-beta.8
    @mui/core-downloads-tracker:  5.14.1
    @mui/icons-material:  5.14.1
    @mui/lab:  5.0.0-alpha.137
    @mui/material:  5.14.1
    @mui/private-theming:  5.13.7
    @mui/styled-engine:  5.13.2
    @mui/system:  5.14.1
    @mui/types:  7.2.4
    @mui/utils:  5.14.1
    @mui/x-data-grid:  6.10.1
    @mui/x-data-grid-premium:  6.10.1
    @mui/x-data-grid-pro:  6.10.1
    @mui/x-date-pickers:  6.10.1
    @mui/x-date-pickers-pro:  6.10.1
    @mui/x-license-pro:  6.10.0
    @types/react:  18.2.14
    react:  18.2.0
    react-dom:  18.2.0
    typescript: 5.1.3 => 5.1.3
@e965 e965 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 20, 2023
@zannager zannager added package: material-ui Specific to @mui/material core Infrastructure work going on behind the scenes labels Jul 21, 2023
@ZeeshanTamboli
Copy link
Member

Duplicate of #38034

@ZeeshanTamboli ZeeshanTamboli marked this as a duplicate of #38034 Jul 21, 2023
@github-actions github-actions bot added duplicate This issue or pull request already exists and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 21, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
sai6855 added a commit to michaldudak/material-ui that referenced this issue Jul 24, 2023
michaldudak pushed a commit to michaldudak/material-ui that referenced this issue Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes duplicate This issue or pull request already exists package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

4 participants