Skip to content

Instantly share code, notes, and snippets.

@rubenRP
Created April 14, 2020 15:39
Show Gist options
  • Save rubenRP/839429aa98f623e297d199b606781a3b to your computer and use it in GitHub Desktop.
Save rubenRP/839429aa98f623e297d199b606781a3b to your computer and use it in GitHub Desktop.
mport React, { Component } from "react"
import { getAllCountriesInfo } from "../api/covid"
import Layout from "../components/Layout/Layout"
import SEO from "../components/Seo/Seo"
import InfoMap from "../components/InfoMap/InfoMap"
import Table from "../components/Table/Table"
class IndexPage extends Component {
constructor(props) {
super(props)
this.state = {
countries: [],
}
}
componentDidMount = () => {
getAllCountriesInfo().then(countries => {
this.setState({ countries: countries })
})
}
render() {
const { countries } = this.state
return (
<Layout>
<SEO title="Home" />
<h1 className="mt-5 mb-4">COVID19 Updated Info</h1>
<div className="row">
<div className="col-12">
<InfoMap countries={countries} />
</div>
<div className="col-12 mt-5">
<h2>Top 15 infected countries overview</h2>
<Table countries={countries.slice(0, 15)} />
</div>
</div>
</Layout>
)
}
}
export default IndexPage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment