2016-07-15 95 views
-1

**得到錯誤的ConsultantlistItem在反應JSX語法**意外標記反應圖()

return this.props.userList.map(function(n,index){ 
       debugger 
       <ConsultantListItem key={index} {...n}/> 

      }); 

但是當我使用lodash

_.map(this.props.userList,function(userList,index) 
    { <ConsultantListItem key={index} {...userList} /> }); 

工作的罰款。

回答

1

return語句必須在map函數內。這是你做錯了什麼。試試這個

{this.props.userList.map(function(n,index){ 
      return 
      <ConsultantListItem key={index} {...n}/> 

     });} 
+0

map函數必須返回一些東西。你的東西沒有任何回報。而是你正在返回地圖功能。嘗試一次。 –