Prop listed on the API doesn't exist on ImageList MUI component

198 Views Asked by At

I'm trying to use the ImageList component. I imported it as follows:

import { ImageList} from "@material-ui/core";

This works just fine. When I add the "variant" prop to the component, however, I start getting errors saying that I'm not matching any of the overloads. I see the variant prop used in their demos and on the API reference.

Error message

I suspect this has something to do with versioning -- I read something about ImageList being MUI v5 alpha. If that's the case I don't know what to do to fix my issue. The linker is finding the module just fine, so I don't know what's wrong.

1

There are 1 best solutions below

0
Matt Schwartz On

I think I answered this myself. I was importing from the v4 version of MUI (@material-ui/core). I had to install v5 and import from here, instead:

import ImageList from '@mui/material/ImageList';

And then the variant prop worked. I was disheartened to find out that breakpoint props don't exist with this component, like they do with Grid. Instead, I had to use MUI's useMediaQuery hook to get the screen size and set the col prop accordingly.