Created
November 2, 2020 16:36
-
-
Save mirsahib/f46307bcd31f2cfa79b6be7941283656 to your computer and use it in GitHub Desktop.
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 React, { useState } from "react"; | |
import Header from "./components/header"; | |
import SearchBar from "./components/SearchBar"; | |
import Home from "./components/Home"; | |
import Footer from "./components/footer"; | |
function App() { | |
const [cityName, setCityName] = useState(""); | |
//function to track change in the search bar | |
const handleChange = (e) => { | |
setCityName(e.target.value); | |
}; | |
//function to perfom api request | |
const handleSubmit = (e) => { | |
e.preventDefault(); | |
console.log(cityName); | |
setCityName(""); | |
}; | |
return ( | |
<div className=""> | |
<Header /> | |
<SearchBar | |
value={cityName} | |
onChangeValue={handleChange} | |
handleSubmit={handleSubmit} | |
/> | |
<Home /> | |
<Footer /> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment