Skip to content

Commit

Permalink
Adding loading state.
Browse files Browse the repository at this point in the history
  • Loading branch information
erinesullivan committed Aug 5, 2024
1 parent 50fd0e5 commit a299dcc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/browse/components/ShelfBrowse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ShelfBrowse = () => {

useEffect(() => {
const fetchShelfData = async () => {
setShelfData('loading');
try {
const response = await fetch(`https://search.lib.umich.edu/catalog/browse/carousel?query=${callNumber}`);
if (!response.ok) {
Expand All @@ -43,6 +44,10 @@ const ShelfBrowse = () => {
return null;
}

if (shelfData === 'loading') {
return <p>Loading...</p>;
}

return <ShelfBrowseCarousel {...{ callNumber, items: shelfData, uid }} />;
};

Expand Down

0 comments on commit a299dcc

Please sign in to comment.