相关疑难解决方法(0)

如何解决“不将对象用作类型”的错误?

我不明白这个错误信息引起的。

我的组件有两个和一个包含对象的数据数组。

我收到一条错误消息“不要object用作类型。该object类型目前难以使用'。

我该如何解决?

我附上了数组有对象的数据。

first.tsx...
import { dataList } from './xxx';
   // This dataList === 
export const dataList = [
  {
    id: 1,
    title: "text",
    hidden1: "text",
  },
  {
    id: 2,
    title: "text",
    hidden1: "text",
    hidden2: "text",
  },
  {
    id: 3,
    title: "text",
    hidden1: "text",
    hidden2: "text",
    hidden3: "text",
  },
];

const First = () => {
  return <Second data={dataList} />
}

second.tsx...
const Second = ({data} : { data:object[] } ) => {.    << …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

4
推荐指数
1
解决办法
6904
查看次数

标签 统计

reactjs ×1

typescript ×1