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

Some error or problem with mui theme creation in typescript? (Why not response me?) #32700

Closed
2 tasks done
siamahnaf opened this issue May 9, 2022 · 1 comment
Closed
2 tasks done
Assignees
Labels
bug 🐛 Something doesn't work typescript

Comments

@siamahnaf
Copy link

siamahnaf commented May 9, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version
import { createTheme } from '@mui/material/styles';

declare module '@mui/material/styles' {
    interface BreakpointOverrides {
        xs: true;
        sm: true;
        msm: true;
        lsm: true;
        smd: true;
        md: true;
        lg: true;
        xxl: true;
    }
}
const theme = createTheme({
    breakpoints: {
        values: {
            xs: 0, // Extra Small Devices ---- Defualt BreakPoints
            sm: 480, // Small Devices ---- Default BreakPoints
            msm: 576, // Medium Small Medium Devices
            lsm: 640, // Large Small Medium Devices
            smd: 768, // Small Medium Devices
            md: 992, // Medium Devices ---- Default BreakPoints
            lg: 1200, // Large Devices  ---- Default BreakPoints
            xxl: 1536, // Large Devices
        },
    }
});
export default theme;

Then why can't I use this custom breakpoint in Grid components? Why give it an error message? How can I solve it?

Here is the usage-

const Home: NextPage = () => {
  return (
    <Box>
      <Seo />
      <Siam />
      <Grid container spacing={0}>
        <Grid item smd={6}><Movies /></Grid> // In this line I am getting error for adding smd
        <Grid item smd={6}><Books /></Grid> // In this line I am getting error for adding smd
      </Grid>
    </Box>
  );
};
export default Home;

Here is the error message-

No overload matches this call.
Overload 1 of 2, '(props: { component: ElementType<any>; } & SystemProps<Theme> & { children?: ReactNode; classes?: Partial<GridClasses> | undefined; ... 14 more ...; zeroMinWidth?: boolean | undefined; } & CommonProps & Omit<...>): Element', gave the following error. Property 'component' is missing in type '{ children: Element; item: true; smd: number; }' but required in type '{ component: ElementType<any>; }'. Overload 2 of 2, '(props: DefaultComponentProps<GridTypeMap<{}, "div">>): Element', gave the following error. Type '{ children: Element; item: true; smd: number; }' is not assignable to type 'IntrinsicAttributes & SystemProps<Theme> & { children?: ReactNode; classes?: Partial<GridClasses> | undefined; ... 14 more ...; zeroMinWidth?: boolean | undefined; } & CommonProps & Omit<...>'. Property 'smd' does not exist on type 'IntrinsicAttributes & SystemProps<Theme> & { children?: ReactNode; classes?: Partial<GridClasses> | undefined; ... 14 more ...; zeroMinWidth?: boolean | undefined; } & CommonProps & Omit<...>'.ts(2769) OverridableComponent.d.ts(17, 7): 'component' is declared here.

Here are the error images-
Screenshot (8)

@siamahnaf siamahnaf added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 9, 2022
@siamahnaf siamahnaf changed the title Some error or problem with mui theme creation in typescript? Some error or problem with mui theme creation in typescript? (Why not response me?) May 9, 2022
@siriwatknp
Copy link
Member

siriwatknp commented May 24, 2022

The custom breakpoints on Grid are not working well in typescript. There are ongoing efforts to make it works in:

@siriwatknp siriwatknp added bug 🐛 Something doesn't work typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work typescript
Projects
None yet
Development

No branches or pull requests

3 participants