Lambert
Lambert

Reputation: 2433

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.

Upvotes: 53

Views: 47125

Answers (1)

Sergio Flores
Sergio Flores

Reputation: 5427

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

Upvotes: 116

Related Questions