fix: SW-967 Fixed bad setState call error
This commit is contained in:
@@ -73,7 +73,6 @@ export default function HotelCardListing({
|
|||||||
|
|
||||||
const hotels = useMemo(() => {
|
const hotels = useMemo(() => {
|
||||||
if (activeFilters.length === 0) {
|
if (activeFilters.length === 0) {
|
||||||
setResultCount(sortedHotels.length)
|
|
||||||
return sortedHotels
|
return sortedHotels
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,9 +84,8 @@ export default function HotelCardListing({
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
setResultCount(filteredHotels.length)
|
|
||||||
return filteredHotels
|
return filteredHotels
|
||||||
}, [activeFilters, sortedHotels, setResultCount])
|
}, [activeFilters, sortedHotels])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
@@ -99,6 +97,10 @@ export default function HotelCardListing({
|
|||||||
return () => window.removeEventListener("scroll", handleScroll)
|
return () => window.removeEventListener("scroll", handleScroll)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setResultCount(hotels ? hotels.length : 0)
|
||||||
|
}, [hotels, setResultCount])
|
||||||
|
|
||||||
function scrollToTop() {
|
function scrollToTop() {
|
||||||
window.scrollTo({ top: 0, behavior: "smooth" })
|
window.scrollTo({ top: 0, behavior: "smooth" })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user