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

docs: clarify usage of useSWRMutation with optimisticData #584

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pages/docs/mutation.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -344,6 +345,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## Rollback on Errors [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.es-ES.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -345,6 +346,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## Rollback on Errors [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.fr-FR.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -339,6 +340,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## Revenir en arrière sur les erreurs [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.ja.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -345,6 +346,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## エラー時のロールバック [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -344,6 +345,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## 오류 시 롤백 [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.pt-BR.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -339,6 +340,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## Reversão de Erros [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.ru.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -344,6 +345,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## Откат при ошибках [#rollback-on-errors]

Expand Down
3 changes: 3 additions & 0 deletions pages/docs/mutation.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ import useSWRMutation from 'swr/mutation'

function Profile () {
const { trigger } = useSWRMutation('/api/user', updateUserName)
const { data } = useSWR('/api/user', fetcher)

return (
<div>
Expand All @@ -339,6 +340,8 @@ function Profile () {
)
}
```
Note that the value provided for `optimisticData` should be based on the data
returned from `useSWR` as opposed to `useSWRMutation`'s data.

## 错误回滚 [#rollback-on-errors]

Expand Down