2016-04-07 90 views
1

我試圖用這個寶石:使用npm陣營組件進口不承認

npm install react-component-gallery 

http://kyleamathews.github.io/react-component-gallery/

所以我安裝了它,我創造了這樣一個陣營組成:

var Gallery = React.createClass({ 

    render: function() { 
    return (

    <ComponentGallery 
    className="example" 
    margin=10 
    noMarginBottomOnLastRow=true 
    widthHeightRatio=3/5 
    targetWidth=250> 
     <img src="https://example.com/pic1.jpg" /> 
     <img src="https://example.com/pic2.jpg" /> 
     <img src="https://example.com/pic3.jpg" /> 
     <img src="https://example.com/pic4.jpg" /> 
     <img src="https://example.com/pic5.jpg" /> 
     <img src="https://example.com/pic6.jpg" /> 
     <img src="https://storage.googleapis.com/relaterocket-logos/[email protected]" /> 
     <img src="https://storage.googleapis.com/relaterocket-logos/[email protected]" /> 
    </ComponentGallery> 
    ); 
    } 

}); 

但是我收到此錯誤:

JSX value should be either an expression or a quoted JSX t 
ext (10:11) 

其中第10行是這樣的:

margin=10 

爲什麼會發生這種情況?

回答

1

JSX與XML相似。您的屬性值需要帶引號的字符串,表達式或其他JSX元素。就你而言,例如

margin="10" 
noMarginBottomOnLastRow={true} 

(第二可"true",只是給一個表達式的一個例子。)