In the following code, I want to make the "checked" attribute of the input
dynamic. Obviously completed
is a boolean. The compilation fails right at the start of {check}
with the error TS1005: '...' expected.
import React from 'react';
export class TodoListItem extends React.Component<any, any> {
render() {
const {label, completed} = this.props;
const check = completed? "checked": " ";
return (
<li className="todo">
<label>
<input type="checkbox" {check}/> {label}
</label>
</li>
);
}
}