我在尝试创建一个以“date”为键的多映射,然后遍历以数组作为值的多映射时遇到以下错误。
输入 '{children: never[]; 键:字符串;索引:字符串;项目:SomeItem[]; }' 不可分配给类型 'IntrinsicAttributes & Props'。类型“IntrinsicAttributes & Props”上不存在属性“children”。ts(2322)
并且不知道如何解决这个问题
const History = () => {
const [counter, setCounter] = useState(0);
type SomeMap = Map<string, SomeItem[]>;
let map: SomeMap = new Map();
//Items is of type SomeItem[]
Items.foreach((item) =>{
if(map.has(item.date)){
(map.get(item.date) ?? []).push(item);
}
else{
map.set(item.date,[item]);
}
});
return(
<Accordian>
{ map.foreach((value, index) => {
setCounter(counter +1 );
<Task
key={index}
Index={counter.toString()}
Item={value}>
</Task>
})}
</Accordian>
);
};
type Props = {
index: string;
Item: SomeItem[];
};
const …Run Code Online (Sandbox Code Playgroud)