Post 60b361c747496
Post 60b361c747496
<title>Corona App</title>
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
/>
Basic Material UI
Create Table with Material UI
Import Component
const rows = [
{name: 'Onesinus SPT', age: 17},
{name: 'Ucok', age: 62}
];
return (
<TableContainer component={Paper}>
<Table className={classes.table} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>Age</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.name}>
<TableCell>{row.name}</TableCell>
<TableCell>{row.age}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)
Tools / Package for Fetch data
Fetch Methods
Common response type fetch
Tools for hit API ( Rest Client )
Complete React Life Cycle
Common Life Cycle
https://api.thevirustracker.com/free-api?countryTimeline=ID
Try Fetch in console
Implement in code?
import React, { useEffect, useState } from 'react';
useEffect(() => {
fetch('https://api.thevirustracker.com/free-api?countryTimeline=ID')
.then(response => { return response.json() } )
.then(data => {
setRows(data.timelineitems[0]);
});
}, []);
return (
<TableContainer component={Paper}>
<Table className={classes.table} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Total Cases</TableCell>
<TableCell>Total Recoveries</TableCell>
<TableCell>Total Deaths</TableCell>
</TableRow>
</TableHead>
<TableBody>
{Object.keys(rows).map((key) => (
<TableRow key={key}>
<TableCell>{key}</TableCell>
<TableCell>{rows[key].total_cases}</TableCell>
<TableCell>{rows[key].total_recoveries}</TableCell>
<TableCell>{rows[key].total_deaths}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
Let’s connect
https://github.com/onesinus
https://www.linkedin.com/in/onesinus/