From 158802a73bad86b4bcf26a549fafcc4cb5226c1f Mon Sep 17 00:00:00 2001 From: Miyuru Gunarathna Date: Sat, 23 Sep 2023 22:03:04 +0530 Subject: [PATCH] Fix: reset page when filter or sort something --- src/pages/home.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/home.jsx b/src/pages/home.jsx index 3dcdc4e..5d3b195 100644 --- a/src/pages/home.jsx +++ b/src/pages/home.jsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { ScoreCardSkeleton } from "@/components"; import { ScoreCard } from "@/components/home"; import { filters as filterData, sorts as sortData } from "@/filters"; @@ -17,6 +17,10 @@ const Home = () => { useTitle("Leaderboard | Bashaway"); + useEffect(() => { + if (page !== 1) setPage(1); + }, [filters, sorts]); + return ( <>