Skip to content

Instantly share code, notes, and snippets.

@mrcthms
Last active May 18, 2017 20:29
Show Gist options
  • Save mrcthms/e1c563cfd9dd3465bd4d70e059c14742 to your computer and use it in GitHub Desktop.
Save mrcthms/e1c563cfd9dd3465bd4d70e059c14742 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>
</tr>
));
const Table = ({ propTypes }) => (
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required?</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