fix(useSearchParamToggle): fixed issue where all search params where removed when changing setting
Build and Push Docker image / build-and-push (push) Successful in 1m49s
Details
Build and Push Docker image / build-and-push (push) Successful in 1m49s
Details
This commit is contained in:
parent
cf82f4f957
commit
03bd913d45
|
@ -5,11 +5,21 @@ export const useSearchParamToggle = (key: string) => {
|
|||
|
||||
const value = searchParams.get(key) === "true"
|
||||
|
||||
const open = () => setSearchParams(prev => ({...prev, [key]: "true"}), {replace: true})
|
||||
const close = () => setSearchParams(prev => {
|
||||
prev.delete(key)
|
||||
return prev
|
||||
const open = () => {
|
||||
setSearchParams(prev => {
|
||||
const newParams = new URLSearchParams(prev);
|
||||
newParams.set(key, "true")
|
||||
return newParams
|
||||
}, { replace: true })
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
setSearchParams(prev => {
|
||||
const newParams = new URLSearchParams(prev);
|
||||
newParams.delete(key);
|
||||
return newParams;
|
||||
}, { replace: true })
|
||||
}
|
||||
|
||||
return {
|
||||
value: value,
|
||||
|
|
Loading…
Reference in New Issue