Skip to content

Commit

Permalink
Lifting up the countryData State
Browse files Browse the repository at this point in the history
 Closes #9
  • Loading branch information
Augustine-edeh committed Mar 25, 2023
1 parent 1780263 commit 6484b9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ function App() {
setErrStatus((previous) => status);
};

const receiveCountryDataHandler = (countryData) => {
console.log(countryData);
};

return (
<div className="App">
<Header />

<main className="App-main">
<Title />
<SearchForm onEmptyInput={emptyInputHandler} />
<SearchForm
onEmptyInput={emptyInputHandler}
onReceiveCountryData={receiveCountryDataHandler}
/>
{errStatus ? (
<p className="App-empty-search_Error">Please enter a country name</p>
) : (
Expand Down
3 changes: 2 additions & 1 deletion src/Components/SearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const SearchForm = (props) => {
fetch(countryURL)
.then((response) => response.json())
.then((countryData) => {
console.log(countryData);
// console.log(countryData);
props.onReceiveCountryData(countryData);
})
.catch((err) => console.log(err));
} else {
Expand Down

0 comments on commit 6484b9f

Please sign in to comment.