【发布时间】:2021-11-19 02:51:54
【问题描述】:
错误:
类型 'void' 不可分配给类型 'ReactNode'.ts(2322)
index.d.ts(1354, 9):预期类型来自属性“children”,该属性在此处声明为“DetailedHTMLProps
”类型
代码:
interface Item{
item: string;
type: string;
answer: string;
answers: Array<any>;
}
interface Props {
items: Item[];
}
//this is the line where the error is being stated
this.props.items[0].answers.forEach((item) => console.log(item));
我要做的就是遍历数组并将其注销。数组可以是数字/字符串。
我正在尝试将 props 数组分散到它自己的数组实例中,并且发生了同样的错误。
【问题讨论】:
-
请提供其余代码。仅您的代码不会导致此类错误
标签: arrays reactjs typescript