Skip to content

Instantly share code, notes, and snippets.

@mrcthms
Created May 18, 2017 20:52
Show Gist options
  • Save mrcthms/b029c18067acfc3d299ab0dd1b2dae18 to your computer and use it in GitHub Desktop.
Save mrcthms/b029c18067acfc3d299ab0dd1b2dae18 to your computer and use it in GitHub Desktop.
import React from 'react';
import PropTypes from 'prop-types';
import './Table.css';
const getRows = propTypes => Object.keys(propTypes).map(prop => (
<tr key={prop}>
<td>{prop}</td>
<td>{propTypes[prop].type}</td>
<td>{propTypes[prop].required.toString()}</td>
<td>{propTypes[prop].description}</td>
</tr>
));
const Table = ({ propTypes }) => (
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required?</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{getRows(propTypes)}
</tbody>
</table>
);
Table.propTypes = {
propTypes: PropTypes.object.isRequired
}
export default Table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment