Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SyntaxError意外标记,应为“1”&引用;_Javascript_Reactjs - Fatal编程技术网

Javascript SyntaxError意外标记,应为“1”&引用;

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

我有一个错误:

SyntaxError意外标记,应为“,”)

代码:

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>
);