Created
May 18, 2017 20:52
-
-
Save mrcthms/b029c18067acfc3d299ab0dd1b2dae18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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