Skip to content

Commit

Permalink
Add Loading Effect for Search Queries
Browse files Browse the repository at this point in the history
  • Loading branch information
kaamil-ahamadh committed Nov 18, 2022
1 parent a59af32 commit 9f44ed4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ function App() {

const handleSearchApi = async (userSearch) => {
try {
setLoading(true);
const response = await youtubeApiSearch(userSearch);
setSearchResults(response.data.items);
setUserSearch("");

//Navigate
navigate(`/search/${userSearch}`);

setLoading(false);
} catch (error) {
console.log(error);
}
Expand All @@ -74,7 +77,11 @@ function App() {
</div>
<div className="screen-container">
<GlobalContext.Provider
value={{ trendingVideos, setTrendingVideos, searchResults }}
value={{
trendingVideos,
setTrendingVideos,
searchResults,
}}
>
<Routes>
<Route path="/" element={<HomeScreen />} />
Expand Down

0 comments on commit 9f44ed4

Please sign in to comment.