简体   繁体   English

React.js - 无法在表中显示数组对象

[英]React.js - Cant display array object in table

I cant display array object in map function. 我无法在地图功能中显示数组对象。 Could someone please tell me why ? 有人可以告诉我为什么吗? When Im trying to display this object in the console I see it correctly. 当我试图在控制台中显示此对象时,我正确地看到它。

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>);
}}

您的map函数需要return语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM