I am new to React and TypeScript. I want to set an attribute if a prop is true (boolean).
I am using Material UI's button, which can take disabled prop, eg <Button disabled>Disabled</Button>.
I have the following:
interface sectionProps {
title: string;
disabled?: boolean;
}
const Section = ({
title,
disabled,
}: sectionProps) => {
const isDisabled = {disabled ? 'disabled' : ''};
return (
<Button {isDisabled} variant="outlined" color="primary" >
Start
</Button>
)
};
But I get an error on compilation where it seems to want to replace the ? in the ternary with a ,. I don't understand this.
Unexpected token, expected ","
Would anyone be able to point me in the right direction?