我有一个毫无意义的错误,我正在用钩子输入我的状态的值,但他说错误是不同的类型。
已经尝试过使用空数组,甚至是带有一些数据的数组,并且总是错误相同。
import React, { useState } from 'react';
import { Row, Col } from 'config/styles';
import Bed from './Bed';
interface DataTypes {
date: string;
value: number;
}
function Beds(): JSX.Element {
const { data, setData } = useState<DataTypes[]>([]);
return (
<>
<Row>
{data.map((d, i) => (
<Col key={i} sm={16.666} lg={10}>
<Bed {...d} />
</Col>
))}
</Row>
</>
);
}
export default Beds;
错了:
TypeScript error in /Users/keven/Documents/carenet/orquestra-frontend/src/Beds/index.tsx(11,11):
Property 'data' does not exist on type '[DataTypes[], Dispatch<SetStateAction<DataTypes[]>>]'