Last active
May 18, 2017 20:29
-
-
Save mrcthms/e1c563cfd9dd3465bd4d70e059c14742 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> | |
</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