Javascript SyntaxError意外标记,应为“1”&引用;
我有一个错误: SyntaxError意外标记,应为“,”) 代码:Javascript SyntaxError意外标记,应为“1”&引用;,javascript,reactjs,Javascript,Reactjs,我有一个错误: SyntaxError意外标记,应为“,”) 代码: render(){ const{collections}=this.state; 返回( { collections.map({id,…otherCollectionProps}=>{ }) } ) } 解构参数周围需要括号 ({ id, ...otherCollectionProps }) => () 您还应该使用return或简单的括号(而不是大括号)返回JSX const{collections}=this.st
render(){
const{collections}=this.state;
返回(
{
collections.map({id,…otherCollectionProps}=>{
})
}
)
}
解构参数周围需要括号
({ id, ...otherCollectionProps }) => ()
您还应该使用return
或简单的括号(而不是大括号)返回JSX
const{collections}=this.state;
返回(
{collections.map({id,…otherCollectionProps})=>{
返回;
})}
);
如果您喜欢我的答案,或者您从我的答案中得到了任何帮助,请不要忘记考虑向上投票,并单击向右箭头,检查此答案是否为您的最佳答案,谢谢!
({ id, ...otherCollectionProps }) => ()
const { collections } = this.state;
return (
<div className="shop-page">
{collections.map(({ id, ...otherCollectionProps }) => {
return <PreviewCollection key={id} {...otherCollectionProps} />;
})}
</div>
);