I have a problem using MUI with react-router-dom v6.
import ListItem from '@mui/material/ListItem';
import { NavLink } from 'react-router-dom';
<List key={index}>
<ListItem
component={NavLink}
sx={{
color: '#8C8C8C',
}}
to={'/home'}
className={({ isActive }) => (isActive ? classes.activeLink : undefined)
>
<ListItemIcon></ListItemIcon>
<ListItemText primary='Home'/>
</ListItem>
</List>
className
not working and show error:
No overload matches this call.
The last overload gave the following error.
Type '({ isActive }: { isActive: any; }) => boolean' is not assignable to type 'string'
The expected type comes from property 'className' which is declared here on type 'IntrinsicAttributes & { button?: false | undefined; } & ListItemBaseProps & { components?: { Root?: ElementType<any> | undefined; } | undefined; componentsProps?: { ...; } | undefined; } & CommonProps & Omit<...>'
NavLink
component fromReactRouter
. Although this remains magical to me, it is at least magic that works -- after I've spent a long time thrashing at alternatives. I've upvoted this, and at least for me it is the answer to my own question that brought me here. Kudo's to @Ladybug for posting this. – Hillery