2017-04-08 19 views
1

マップ機能でアレイオブジェクトを表示できません。誰かが私になぜ教えてもらえますか?私がこのオブジェクトをコンソールに表示しようとすると、正しく表示されます。React.js - テーブル内の配列オブジェクトを表示する

class ProductsGrid extends React.Component { 
constructor(props) { 
    super(props); 
} 
render() { 
    return (<Table striped bordered condensed hover> 
     <thead> 
      <tr> 
       <th>Id</th> 
       <th>Name</th> 
       <th>Description</th> 
       <th>Url</th> 
      </tr> 
     </thead> 
     <tbody> 
      {this.props.products !== null ? 
       JSON.parse(this.props.products).map((product, index) => { 
        <tr> 
         {console.log(product.IdProduct)} 
         <td>{product.IdProduct}</td> 
         <td>{product.Name}</td> 
         <td>{product.Description}</td> 
         <td>{product.UrlFriendlyName}</td> 
        </tr> 
       }) : <tr><td></td><td></td><td></td><td></td></tr>} 
     </tbody> 
    </Table>); 
}} 
+6

あなたのマップ機能はリターンが必要ですか? –

+0

もちろん...愚かな間違い、すみません。私はこれを1時間のように過ごしています。 – TjDillashaw

+0

何十年もプログラミングの間違いの多くを作りました:-)私の答えがこれを行う次の人に役立つことを願っています。 –

答えて

3

マップ関数にreturn文が必要です。

関連する問題