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

[React Typescript] Generic function component

发布时间 2023-08-11 15:06:21作者: Zhentiw
export const Table = <T>(props: TableProps<T>) => {
  return (
    <table>
      <tbody>
        {props.rows.map((row) => (
          <tr>{props.renderRow(row)}</tr>
        ))}
      </tbody>
    </table>
  );
};

 

Because ti's a tsx file, the way to fix it:

export const Table = <T,>(props: TableProps<T>) => {

or 

export const Table = <T extends unknown>(props: TableProps<T>) => {

 

    本栏目推荐文章
  • 2024-01-13 记录react-dnd拖拽组件的用法
  • 2024-01-13 react 监听上一页返回
  • 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. ==》引用了未使用的方法导致
  • 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".
  • pm2启动react项目总是stopped
  • react 横向文字滚动动画 ,及纵向文字滚动动画带有间歇时间 交替渐变显示文字动画
  • [TypeScript]介绍及安装
  • koa2 使用koa-body引入报错 koaBody is not a function
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们