【发布时间】:2022-01-09 23:29:39
【问题描述】:
我在我的项目中使用 typescript 和 react,我创建了一个简单的组件,我想在其中映射一个列表并创建 react 元素:
const FlightSchedule: React.FC<{ flightRoute: List<Entity<FlightLeg>> }> = ({flightRoute}) => flightRoute.map(route =>
<DescriptionList key={route.get('flightId')}>
<TermDescriptionGroup description={route.get('flightId')}/>
<TermDescriptionGroup description={route.get('flightDate')} topMargin/>
</DescriptionList>)
但是,我收到以下打字稿错误:
Type 'List<Element>' is missing the following properties from type 'ReactElement<any, any>': type, props, key
为什么会出现这个错误,我在这里做错了什么?
【问题讨论】:
-
我认为您需要向我们展示
List、Entity和FlightLeg是什么。
标签: reactjs typescript