【问题标题】:How to pre type array of React Elements in typescript如何在打字稿中预先输入 React 元素数组
【发布时间】:2020-03-14 05:44:58
【问题描述】:
import { Button, ButtonGroup } from '@material-ui/core';
let buttons: React.Component[] = [];

返回:类型“Element”缺少类型“Component”的以下属性:context、setState、forceUpdate、render 和另外 2 个。 TS2740

let buttons: Buttons[] = [];

返回:'Button' 指的是一个值,但在这里被用作一个类型。 TS2749

声明类型化的 React 元素数组的正确方法是什么?

【问题讨论】:

    标签: javascript reactjs typescript material-ui


    【解决方案1】:

    我公司的一位开发人员告诉我:

    let buttons: JSX.Element[] = [];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-30
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2022-10-12
      • 2018-10-21
      • 1970-01-01
      相关资源
      最近更新 更多