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()}}/>
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()} />