Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add "colSpan" attribute in ReactJS

I'm getting the error "Type string is not assignable to type number" when I try to add a colSpan="2" attribute to the below ReactJS TypeScript code. How can I fix this?

class ProductCategoryRow extends React.Component<MyProps, MyState> {    constructor(props: MyProps) {       super(props);    }    render() {       return (<div>          <tr><th colSpan="2">{ this.props.category }</th></tr>       </div>);    } //end render. } //end class. 
like image 752
Lambert Avatar asked Jun 01 '16 20:06

Lambert


People also ask

What is colSpan attribute?

Definition and Usage The colspan attribute defines the number of columns a table cell should span.


1 Answers

Have you tried <th colSpan={2}>{ this.props.category}</th>?

like image 113
Sergio Flores Avatar answered Oct 07 '22 14:10

Sergio Flores