JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

[React Typescript] Generics in Class Component

发布时间 2023-08-12 16:12:43作者: Zhentiw
interface TableProps<T> {
  rows: T[];
  renderRow: (row: T) => ReactNode;
}

export class Table<T> extends React.Component<TableProps<T>> {
  render(): ReactNode {
    return (
      <table>
        <tbody>
          {this.props.rows.map((row) => (
            <tr>{this.props.renderRow(row)}</tr>
          ))}
        </tbody>
      </table>
    );
  }
}

 

    本栏目推荐文章
  • 2024-01-13 记录react-dnd拖拽组件的用法
  • 2024-01-13 react 监听上一页返回
  • arthas热更新class
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • JVM学习-Class文件结构
  • Templates Generics 模板 范型
  • 002*:React状态、属性、传值
  • react-native在windows环境搭建并使用脚手架新建工程
  • [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
  • SpringBoot配置报错:Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们