Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
Material-UI TypeScript issue creating styled ListItemButton with Link as the component

I am attempting to create a styled ListItemButton that changes the hover backgroundColor. This component will be used from multiple components which is why I am doing this. The issue is that when using this NavigationListItemButton with a react-router-dom Link as the component it fails TS checking. How can I do this with 'component' and 'to' props? Any help would be appreciated.

import { Theme, styled, alpha } from '@mui/material';
import ListItemButton from '@mui/material/ListItemButton';

const NavigationListItemButton = styled(ListItemButton)(
  ({ theme }: { theme?: Theme }) => ({
    '&:hover': {
      backgroundColor: alpha(theme.palette.secondary.main, 0.5),
    },
  }),
);

export default NavigationListItemButton;
import React from 'react';
import { Link } from 'react-router-dom';
import { ListItemText } from '@mui/material';

import NavigationListItemButton from '../NavigationListItemButton';

const OpsManagerListItem: React.FC<{ navigationOpen: boolean }> = ({
  navigationOpen,
}) => {
  return (
    <NavigationListItemButton component={Link} to={'toHere'}>
      <ListItemText primary={'Ops Manager'} />
    </NavigationListItemButton>
  );
};

export default React.memo(OpsManagerListItem);

Type '{ children: Element; component: <S = unknown>(props: LinkProps & RefAttributes) => ReactElement<any, string | JSXElementConstructor>; to: string; }' is not assignable to type 'IntrinsicAttributes & ListItemButtonBaseProps & Omit<{ action?: Ref; centerRipple?: boolean; ... 11 more ...; TouchRippleProps?: Partial<...>; }, "classes"> & ... 5 more ... & { ...; }'. Property 'component' does not exist on type 'IntrinsicAttributes & ListItemButtonBaseProps & Omit<{ action?: Ref; centerRipple?: boolean; ... 11 more ...; TouchRippleProps?: Partial<...>; }, "classes"> & ... 5 more ... & { ...; }'.ts(2322)

https://codesandbox.io/s/listitembutton-styled-dusbv?file=/src/OpsManagerListItem.tsx

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda