fix(search): move router updates out of state updaters
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user