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 value = searchParams.get(key) === "true"
|
||||||
|
|
||||||
const open = () => setSearchParams(prev => ({...prev, [key]: "true"}), {replace: true})
|
const open = () => {
|
||||||
const close = () => setSearchParams(prev => {
|
setSearchParams(prev => {
|
||||||
prev.delete(key)
|
const newParams = new URLSearchParams(prev);
|
||||||
return prev
|
newParams.set(key, "true")
|
||||||
|
return newParams
|
||||||
}, { replace: true })
|
}, { replace: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
setSearchParams(prev => {
|
||||||
|
const newParams = new URLSearchParams(prev);
|
||||||
|
newParams.delete(key);
|
||||||
|
return newParams;
|
||||||
|
}, { replace: true })
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value: value,
|
value: value,
|
||||||
|
|
Loading…
Reference in New Issue