Created
April 25, 2022 09:23
-
-
Save petrosDemetrakopoulos/4c5ee345410987349b52b3ce2e34b8cb to your computer and use it in GitHub Desktop.
TableList custome component
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 styled from 'styled-components' | |
const StyledTable = styled.table` | |
border: 2px solid black; | |
` | |
const StyledTh = styled.th` | |
border-bottom: 1px solid black; | |
` | |
interface TableRow { | |
name: string | |
surname: string | |
email: string | |
} | |
const TableList: React.FC<{ | |
data: TableRow[] | |
}> = ({ data }) => { | |
return ( | |
<StyledTable> | |
<tr> | |
<StyledTh>Name</StyledTh> | |
<StyledTh>Surname</StyledTh> | |
<StyledTh>Email</StyledTh> | |
</tr> | |
{data.map((val, key) => { | |
return ( | |
<tr key={key}> | |
<td>{val.name}</td> | |
<td>{val.surname}</td> | |
<td>{val.email}</td> | |
</tr> | |
) | |
})} | |
</StyledTable> | |
) | |
} | |
export default TableList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment