T
TanStack2y ago
absent-sapphire

mask all search params except one

Any idea how I could implement this? I know when I mask, I have access to the previous value of the search params. But if I'm doing the following navigation:
{to: "/someRoute", search: {foo: "bar", hello:"world"}}
{to: "/someRoute", search: {foo: "bar", hello:"world"}}
how can I only keep the foo search param?
1 Reply
absent-sapphire
absent-sapphireOP2y ago
ah, for context: this is in a reusable navigate function:
// something like this
const modifiedOptions: NavigateOptions = {
...restOfOptions,
mask: {
params: parsedParams,
// I want to always keep foo in the URL through something like below

search: {foo: true},
}
};

await navigate(modifiedOptions)
// something like this
const modifiedOptions: NavigateOptions = {
...restOfOptions,
mask: {
params: parsedParams,
// I want to always keep foo in the URL through something like below

search: {foo: true},
}
};

await navigate(modifiedOptions)
I was thinking that I could check the value of the search being passed into this navigate() wrapper, but the value of it is either true | object | function that returns an object so im not sure how to check if search.foo was defined

Did you find this page helpful?