Nic*_*icc 5 javascript reactjs
我正在使用由linter eslint-plugin-react解析的以下代码。它返回警告:
“道具验证中缺少产品”
当我在底部的propTypes中声明product时,我将其传递给函数。任何的想法 ?
import React from 'react'
const ProductDesc = (props)=>({
render(){
return (
<div>
<h1>{props.product.headline}</h1>
<img src={props.product.images[0].imagesUrls.entry[2].url} alt="Thumbnail large pic"/>
<p>Yeah</p>
</div>
)
}
})
ProductDesc.propTypes = {
product: React.PropTypes.object
};
export default ProductDesc;
Run Code Online (Sandbox Code Playgroud)
Nic*_*icc -3
语法应该是
const ProductDesc = (props)=>{
return (
<div>
<h1>{props.product.headline}</h1>
<p>Yeah</p>
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2948 次 |
| 最近记录: |