Skip to content

Commit

Permalink
Solved Loading issue in Snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
srakhee committed Jan 8, 2022
1 parent 406d695 commit 594298e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/context/PhotoContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const PhotoContextProvider = props => {
const [images, setImages] = useState([]);
const [loading, setLoading] = useState(true);
const runSearch = query => {
setLoading(true);
axios
.get(
`https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=${apiKey}&tags=${query}&per_page=24&format=json&nojsoncallback=1`
Expand All @@ -16,6 +17,7 @@ const PhotoContextProvider = props => {
setLoading(false);
})
.catch(error => {
setLoading(false);
console.log(
"Encountered an error with fetching and parsing data",
error
Expand Down

1 comment on commit 594298e

@rakheesingh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR addresses my proposal of Yog9#39 Add a spinner when the search button(api is called) is clicked. Yog9#39

Please sign in to comment.