refactor(react-hooks): enable stricter effect rules

Turn on react-hooks/set-state-in-effect and react-hooks/incompatible-library, then remove effect-driven local state sync patterns across affected pages. Keep behavior stable by deriving values from source state, remounting tab state by role key, and replacing useForm watch with useWatch.
This commit is contained in:
zetaloop
2026-02-22 10:03:00 +08:00
parent c9dbf5037e
commit 519fb92c34
9 changed files with 36 additions and 59 deletions
+4 -8
View File
@@ -377,19 +377,15 @@ function SearchPageContent() {
const game = searchParams.get("game")
return game ? [game] : []
})
const [priceRange, setPriceRange] = useState<{ min: string; max: string }>({ min: "", max: "" })
const [priceRange, setPriceRange] = useState<{ min: string; max: string }>({
min: "",
max: "",
})
const [onlyOnline, setOnlyOnline] = useState(false)
const [minRating, setMinRating] = useState("0")
const [sortBy, setSortBy] = useState("composite")
const [visibleCount, setVisibleCount] = useState(12)
useEffect(() => {
const q = searchParams.get("q")
if (q !== null && q !== searchQuery) {
setSearchQuery(q)
}
}, [searchParams, searchQuery])
useEffect(() => {
const timer = setTimeout(() => {
const params = new URLSearchParams(searchParams.toString())