fix(search): move router updates out of state updaters

This commit is contained in:
zetaloop
2026-04-24 09:19:38 +08:00
parent adfded0e40
commit 8813f7493f
+9 -9
View File
@@ -482,20 +482,22 @@ function SearchPageContent() {
}, [searchParams])
const handleGameChange = (game: string, checked: boolean) => {
setSelectedGames((prev) => {
const next = checked ? [...new Set([...prev, game])] : prev.filter((g) => g !== game)
const next = checked
? [...new Set([...selectedGames, game])]
: selectedGames.filter((item) => item !== game)
setSelectedGames(next)
replaceUrl((params) => {
params.delete("game")
for (const g of next) params.append("game", g)
for (const value of next) params.append("game", value)
resetPagination(params)
})
return next
})
}
const handlePriceChange = (type: "min" | "max", value: string) => {
setPriceRange((prev) => {
const next = { ...prev, [type]: value }
const next = { ...priceRange, [type]: value }
setPriceRange(next)
replaceUrl((params) => {
if (next.min) params.set("min", next.min)
else params.delete("min")
@@ -503,8 +505,6 @@ function SearchPageContent() {
else params.delete("max")
resetPagination(params)
})
return next
})
}
const handleOnlineChange = (checked: boolean) => {