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

Required return type when mutating #1769

Closed
gt-codes opened this issue Jan 6, 2022 · 0 comments · Fixed by #1772
Closed

Required return type when mutating #1769

gt-codes opened this issue Jan 6, 2022 · 0 comments · Fixed by #1772
Labels

Comments

@gt-codes
Copy link

gt-codes commented Jan 6, 2022

Bug report

Description / Observed Behavior

When using mutate from useSWR<User>, the async function I have to pass must return User as well. This makes me have to do a bit more in my api. For example: my useUpdateUser hook didn't return anything because it didn't need to. I had to update it to return the user. I do this in different parts of my application where it takes a bit more to return the required type.

Expected Behavior

If you have populateCache: false then it's not needed to return the User type since I don't intend on updating the cache.

Repro Steps / Code Example

mutate(useUpdateUser(data), {
  optimisticData: data as User,
  populateCache: true,
  revalidate: true,
  rollbackOnError: true,
});

Additional Context

SWR version: ^1.2.0-beta.0

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

Successfully merging a pull request may close this issue.

2 participants