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

334
Visualizações
How to spread maxWidth property as max-width on a React component? If I pass it down as maxWidth property I get an error

I am getting the following error because I'm probably not spreading the maxWidth property correctly:

Warning: React does not recognize the maxWidth prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase maxwidth instead. If you accidentally passed it from a parent component, remove it from the DOM element.

I believe the error stems from the way I'm spreading the properties to the component:

export const Card = forwardRef<HTMLDivElement, CardProps>(
  ({ outline, elevation, width = 'inherit', maxWidth='650px', isModal, ...props }, ref) => {
    const CardWrapper = isModal ? DialogWrapper : Wrapper 
    return (
      <CardWrapper
        ref={ref}
        {...{ outline, elevation, width, maxWidth, ...props }}
      >
        <CardContent {...{ elevation, isModal, ...props }} />
      </CardWrapper>
    )
  }
)

As you can see I'm spreading maxWidth='650px' when it should be max-width='650'. The problem is that I'm not sure how to spread it using an alias or something

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

maxWidth is actually not a prop on a DOM element. maxWidth is a style and should be used like this <div style={{maxWidth:'650px'}}> or else your CardWrapper accepts maxWidth as prop

about 4 years ago · Juan Pablo Isaza Relatório
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