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

209
Visualizações
How to pass in two arguments to a props function in styled components

I have a styled-components in my React component and it currently uses the props feature on styled components.

I need to style using another property but I keep getting an error when I try to pass it in.

This is what I currently have and this works fine.

border: 1px solid ${(props) => (props.isError ? "red" : "transparent")};

This is what I am trying to achieve:

border: 1px solid ${(props) => props.isError ? theme.Colors.red : "transparent"};

Is there a way to pass in the theme as an additional prop in the props function?

I keep getting this error **Cannot find name 'theme'.**, even though it is being used in other parts of my styled component.

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

0

${({theme, isError}) => ...} is what you're looking for.

You need to destructure all the props out of the props object - or otherwise you'd use props.theme.Colors.red - as props will contain the theme object the way you're writing it.

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