rgncycle-ui/app/components/list.jsx

48 lines
749 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
//destructure props
export default function List({entities}){
if(entities.length>0){
return (
<>
<h1>List</h1>
<h2>Entity List</h2>
<table>
<thead>
<tr>
<th>entity id</th>
<th>entity name</th>
<th>entity lat</th>
<th>entity lon</th>
</tr>
</thead>
<tbody>
{entities.map((item,key) => {
return(
<tr
key={key}
>
<td>{item[0]}</td>
<td>{item[1]}</td>
<td>{item[2]}</td>
<td>{item[3]}</td>
</tr>
)})}
</tbody>
</table>
</>
);
}else{
return (
<>
<h1>List</h1>
<p>List loading...</p>
</>
);
}
}
List.propTypes = {
entities: PropTypes.array,
};