Skip to content

support func argument for swr mutate #2259

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

Open
1 task done
prescottprue opened this issue Apr 22, 2025 · 0 comments
Open
1 task done

support func argument for swr mutate #2259

prescottprue opened this issue Apr 22, 2025 · 0 comments
Labels
bug Something isn't working swr-openapi Relevant to swr-openapi library

Comments

@prescottprue
Copy link

swr-openapi version

5.1.4

Description

Currently the mutate provided by useMutate does not support a filter function argument the same way that swr does. The filter function allows for path matching without filters. For example if you want to invalid /teams with any query params, with swr you can do the following:

const mutate = useMutate()

mutate(
  key => typeof key === 'string' && key.startsWith('/teams?'),
  undefined,
  { revalidate: true }
)

I realize that this will be a bit different with SWR since storage keys are slightly different, but would still be nice to have our own ability to pass this function

Reproduction

Attempt to pass a function to mutate - notice that it does not accept a function the same way that SWR does

Expected result

Calling mutate with custom key settings based on function as you can do with SWR

Extra

@prescottprue prescottprue added bug Something isn't working swr-openapi Relevant to swr-openapi library labels Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swr-openapi Relevant to swr-openapi library
Projects
None yet
Development

No branches or pull requests

1 participant