Reputation: 695
Can you give me a hand with this expression . Basically what i am trying to say is
If props.row.registered
is true
set disabled to be true
or if is props.row.registered
is undefined
set it to false.
<Button
disabled={!props.row.registered ? true : !props.row.registered === undefined ? false : true}
...
/>
Upvotes: 0
Views: 724
Reputation: 3030
Your ternary operator is basically doing this:
if(props.row.registered === true) {
return true;
else {
return false;
}
which can be simplified to:
return props.row.registered;
So for your conditions it would be:
props.row.registered || props.row.registered !== undefined
(based on your statement since your code it's setting disabled to true
if props.row.registered
is false
, which is the opposite of your statement)
Upvotes: 2
Reputation: 130102
Your boolean can have 4 values: false
, true
, undefined
and null
.
disabled={props.row.registered}
should be enough for your use case because undefined
and null
are both falsy.
Upvotes: 1