fix(search): move router updates out of state updaters
This commit is contained in:
+18
-18
@@ -482,28 +482,28 @@ function SearchPageContent() {
|
|||||||
}, [searchParams])
|
}, [searchParams])
|
||||||
|
|
||||||
const handleGameChange = (game: string, checked: boolean) => {
|
const handleGameChange = (game: string, checked: boolean) => {
|
||||||
setSelectedGames((prev) => {
|
const next = checked
|
||||||
const next = checked ? [...new Set([...prev, game])] : prev.filter((g) => g !== game)
|
? [...new Set([...selectedGames, game])]
|
||||||
replaceUrl((params) => {
|
: selectedGames.filter((item) => item !== game)
|
||||||
params.delete("game")
|
|
||||||
for (const g of next) params.append("game", g)
|
setSelectedGames(next)
|
||||||
resetPagination(params)
|
replaceUrl((params) => {
|
||||||
})
|
params.delete("game")
|
||||||
return next
|
for (const value of next) params.append("game", value)
|
||||||
|
resetPagination(params)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePriceChange = (type: "min" | "max", value: string) => {
|
const handlePriceChange = (type: "min" | "max", value: string) => {
|
||||||
setPriceRange((prev) => {
|
const next = { ...priceRange, [type]: value }
|
||||||
const next = { ...prev, [type]: value }
|
|
||||||
replaceUrl((params) => {
|
setPriceRange(next)
|
||||||
if (next.min) params.set("min", next.min)
|
replaceUrl((params) => {
|
||||||
else params.delete("min")
|
if (next.min) params.set("min", next.min)
|
||||||
if (next.max) params.set("max", next.max)
|
else params.delete("min")
|
||||||
else params.delete("max")
|
if (next.max) params.set("max", next.max)
|
||||||
resetPagination(params)
|
else params.delete("max")
|
||||||
})
|
resetPagination(params)
|
||||||
return next
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user