Skip to content

Commit

Permalink
Fix Listings button functionality
Browse files Browse the repository at this point in the history
- the previous and next buttons took people to /browse/PAGENUMBER rather
  than /browse/?page=PAGENUMBER, where the frontend expects the latter.
  Fixed.
- having fixed that, when we go to a new page, the listings do not
  refresh because the useEffect calling handleSearch has never been
  called; the useEffect hook now updates when pageNumber changes.
  • Loading branch information
chennisden committed Aug 6, 2024
1 parent 47d16d9 commit 9abb4d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/src/pages/Browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Browse = () => {

useEffect(() => {
handleSearch();
}, [debouncedSearch]);
}, [debouncedSearch, pageNumber]);

const handleSearch = async () => {
setListingIds(null);
Expand Down Expand Up @@ -90,15 +90,15 @@ const Browse = () => {
{prevButton && (
<button
className="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-l mr-auto"
onClick={() => navigate(`/browse/${pageNumber - 1}`)}
onClick={() => navigate(`/browse/?page=${pageNumber - 1}`)}
>
Previous
</button>
)}
{nextButton && (
<button
className="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-r ml-auto"
onClick={() => navigate(`/browse/${pageNumber + 1}`)}
onClick={() => navigate(`/browse/?page=${pageNumber + 1}`)}
>
Next
</button>
Expand Down

0 comments on commit 9abb4d4

Please sign in to comment.