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

241
Visualizações
How to set props equal to dynamic value?

I am creating an array of Components:

myArray = [<Component isDisabled={myfunction}/>,<Component isDisabled ={myfunction}/>]

and then mapping it out

myArray.map((comp, index) => (comp))

I am trying to conditionally set the value of isDisabled prop with a function:

myfunction ()
{
return false
}

It is not working. I have tried to use arrow functions

<Component isDisabled={()=>myfunction()}/>
<Component isDisabled={()=>(myfunction())}/>
<Component isDisabled={()=>{myfunction()}}/>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are not setting the value of prop "isDisabled" to boolean, you are passing the whole function to it. If you want isDisabled prop to be the result of myFunction execution, you need to write it this way:

<Component isDisabled={myFunction()} />
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