2016-08-22 2 views
4

linter eslint-plugin-react에 의해 구문 분석되는 다음 코드를 사용하고 있습니다. 내가 propTypes 하단에제품를 선언하면서소품 유효성 검사에서 소품이 누락되었습니다.

"제품이 소품 검증에 없습니다"하고 내가 그것을 함수에 전달할 것을 : 그것은 경고를 반환합니다. 어떤 생각?

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; 
+3

유효한 것으로 나타나지 않습니다 정의 된 어떤 구성 요소에 반응하기 때문에 린터가 혼동 될 수 있었을 것이다. 당신은'class'를 만들거나 렌더링 할 것을 반환하는 함수를 사용해야합니다. 함수는'render' 메소드로 객체를 반환합니다. –

+0

* product *가 있는지 확인하지 않으므로 마침내 * React.PropTypes.object.isRequired *를 * propTypes *에 사용해야합니다. –

+0

allright 실제로 컴포넌트를 엉망으로 만든 render()를 제거했습니다. – Nicc

답변

1

구문은

const ProductDesc = (props)=>{ 
    return (
     <div> 
     <h1>{props.product.headline}</h1> 
     <p>Yeah</p> 
     </div> 
    ) 
} 
관련 문제