I am trying to disable a button depending on a couple of conditions.
<Button disabled={((myobject && myobject.name === "bob") || user.registered) ? true : false} >my button</Button>
Essentially, I want to disable the button if myobject.name is "bob" or if the user is registered (eg. user.registered is not nil). As it stands now, the button seems to get disabled if myobject.name is "bob" but it seems to ignore user.registered. What am I doing wrong?
many thanks!
(myobject && myobject.name === "bob")myobject exsits so TRUE and myobject.name === "bob" so TRUE. So since both are TRUE user.registered will not be evaluated because the first part of the OR statement is TRUE. Disabled then gets set to true. There are two ways to fix the logic:((myobject && myobject.name !== "bob") || user.registered) ? true : falseOR((myobject && myobject.name === "bob") || user.registered) ? false: true