如何在不将其元素包含在<div>

时间:2017-04-13 07:03:22

标签: javascript reactjs

render (){

    var table_labels = this.props.labels.map((label,index)=>{   
        return <th key={index} className="mdl-data-table__cell--non-numeric">{label}</th>
    })

    return(
        <table className={`mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp ${s.tableWrapper}`}>
            <thead>
            <tr>
                {table_labels}
            </tr>
            </thead>
             <tbody>
                {this.props.table_data.results.map((row,index)=>
                    <div>
                        <tr key={index}>
                            {this.props.getRow(row)}
                            <td className="mdl-data-table__cell--non-numeric">
                                <button onClick={() => this.showEditTable(index)}>Edit</button>
                            </td>
                        </tr>   
                        <TypeEditListComponent data={[["1","Fix Dent","Right Front Door"],["2","Fix Dent","Right Front Door"],["3","Fix Dent","Right Front Door"]]}/>
                    </div>  
                )}
             </tbody>
        </table>
    );
}

如何在“tbody”中返回元素而不将其元素包含在“div”中,因为它给出了错误“div不能作为tbody的子元素出现.React不允许返回元素而不将它们包装在标记内。” / p>

0 个答案:

没有答案