--- title: Data table type: snippet language: react tags: [components] cover: armchair dateModified: 2020-11-03T21:26:34+02:00 --- Renders a table with rows dynamically created from an array of primitives. - Render a `` element with two columns (`ID` and `Value`). - Use `Array.prototype.map()` to render every item in `data` as a `` element with an appropriate `key`. ```jsx const DataTable = ({ data }) => { return (
{data.map((val, i) => ( ))}
ID Value
{i} {val}
); }; ``` ```jsx const people = ['John', 'Jesse']; ReactDOM.createRoot(document.getElementById('root')).render( ); ```