Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset single param if any others change. #292

Open
ETFairfax opened this issue Oct 2, 2024 · 2 comments
Open

Reset single param if any others change. #292

ETFairfax opened this issue Oct 2, 2024 · 2 comments

Comments

@ETFairfax
Copy link

Hi,

Is it possible to reset a single param if any others change?

I have a pagination param which I would like to reset to 0 if any other filter params change.

I was thinking of something like const { query, setQuery } = useFiltering(queryParamDefaults, () => ({ page: 0 }));

Also, I notice the library hasn't been update all that much recently. Is it still being maintained? If not, are there other solutions you'd recommend?

Many thanks for your hard work 👍

@pbeshai
Copy link
Owner

pbeshai commented Oct 2, 2024

Hmm, I'd probably just do something like:

const [query, setQueryRaw] = useQueryParams(...)
const setQuery = useCallback((newParams) => setQueryRaw({ page: 0, ...newParams }), [setQueryRaw])

I haven't made updates to this lib in a long time mostly because it still works fine for me and I'm quite busy.

@ETFairfax
Copy link
Author

Thank for the response; that seems to be doing the trick 👍
Wrestling with typescript to make it happy....I'll get there 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants