Source:  Twitter logo

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.

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

101 users liked answer #0dislike answer #0101
Sergio Flores profile pic
Sergio Flores

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).