import React, { useState } from 'react'
import { useField, useCountry } from './hooks'
const Country = ({ country }) => {
if (!country) {
return null
}
if (!country.found) {
return (
Country Not Found...
)
}
return (
{country.data.name.common}
Capital: {country.data.capital}
Population: {country.data.population}
)
}
const App = () => {
const nameInput = useField('text')
const [name, setName] = useState('')
const country = useCountry(name)
const fetch = (e) => {
e.preventDefault()
setName(nameInput.value)
}
return (
)
}
export default App