Created
July 16, 2020 17:47
-
-
Save granolocks/d58c86dead22c9d7ec98b325d19eecc7 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
const DumbTable = ({ data }) => { | |
if (!data || data.length === 0) { | |
return <>No data!</> | |
} | |
const columns = Object.keys(data[0]) | |
return ( | |
<table> | |
<thead> | |
<tr> | |
{columns.map(x => ( | |
<th key={JSON.stringify(x)} style={{ padding: '.5em' }}> | |
{x} | |
</th> | |
))} | |
</tr> | |
</thead> | |
<tbody> | |
{data.map(y => ( | |
<tr key={JSON.stringify(y)}> | |
{columns.map(x => ( | |
<td key={JSON.stringify(x)} style={{ padding: '.5em' }}> | |
{y[x]} | |
</td> | |
))} | |
</tr> | |
))} | |
</tbody> | |
</table> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment