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

Extract the documentation of the mutate options in the Mutation page #324

Merged
merged 2 commits into from
Aug 23, 2022
Merged
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
22 changes: 12 additions & 10 deletions pages/docs/mutation.en-US.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Mutation

```js
mutate(key, data, options)
```

## Options

- `optimisticData`: data to immediately update the client cache, usually used in optimistic UI.
- `revalidate`: should the cache revalidate once the asynchronous update resolves.
- `populateCache`: should the result of the remote mutation be written to the cache.
- `populateCache`: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.
- `rollbackOnError`: should the cache rollback if the remote mutation errors.

## Revalidate

You can get the `mutate` function from the `useSWRConfig()` hook, and broadcast a revalidation message
Expand Down Expand Up @@ -68,16 +80,6 @@ function Profile () {

> The **`updateFn`** should be a promise or asynchronous function to handle the remote mutation, it should return updated data.

**Available Options**

**`optimisticData`**: data to immediately update the client cache, usually used in optimistic UI.

**`revalidate`**: should the cache revalidate once the asynchronous update resolves.

**`populateCache`**: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.

**`rollbackOnError`**: should the cache rollback if the remote mutation errors.

## Mutate Based on Current Data

Sometimes, you want to update a part of your data based on the current data.
Expand Down
21 changes: 11 additions & 10 deletions pages/docs/mutation.es-ES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Mutación

```js
mutate(key, data, options)
```

## Options

- `optimisticData`: data to immediately update the client cache, usually used in optimistic UI.
- `revalidate`: should the cache revalidate once the asynchronous update resolves.
- `populateCache`: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.
- `rollbackOnError`: should the cache rollback if the remote mutation errors.

## Revalidar

You can get the `mutate` function from the `useSWRConfig()` hook, and broadcast a revalidation message
Expand Down Expand Up @@ -66,16 +77,6 @@ function Profile () {

> The **`updateFn`** should be a promise or asynchronous function to handle the remote mutation, it should return updated data.

**Available Options**

**`optimisticData`**: data to immediately update the client cache, usually used in optimistic UI.

**`revalidate`**: should the cache revalidate once the asynchronous update resolves.

**`populateCache`**: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.

**`rollbackOnError`**: should the cache rollback if the remote mutation errors.

## Mutar basándose en los datos actuales

A veces, se desea actualizar una parte de los datos en función de los datos actuales.
Expand Down
21 changes: 11 additions & 10 deletions pages/docs/mutation.ja.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# ミューテーション

```js
mutate(key, data, options)
```

## オプション

- `optimisticData`: クライアントキャッシュを直ちに更新するデータで、通常は 楽観的な UI で使用されます。
- `revalidate`: 非同期更新が解決した後、キャッシュを再検証するかどうか。
- `populateCache`: リモートミューテーションの結果をキャッシュに書き込むかどうか。関数も受け取ります。関数はミューテーションの結果と現在の値を引数として受けとり、ミューテーションの結果を返します。
- `rollbackOnError`: リモートミューテーションでエラーが発生した場合、キャッシュをロールバックするかどうか。

## 再検証

`useSWRConfig()` フックから `mutate` 関数を取得し、`mutate(key)` を呼び出すことで、
Expand Down Expand Up @@ -68,16 +79,6 @@ function Profile () {

> **`updateFn`** は、リモートミューテーションを処理するための promise 関数か非同期関数でなければならず、更新されたデータを返す必要があります。

**利用可能なオプション**

**`optimisticData`**: クライアントキャッシュを直ちに更新するデータで、通常は 楽観的な UI で使用されます。

**`revalidate`**: 非同期更新が解決した後、キャッシュを再検証するかどうか。

**`populateCache`**: リモートミューテーションの結果をキャッシュに書き込むかどうか。関数も受け取ります。関数はミューテーションの結果と現在の値を引数として受けとり、ミューテーションの結果を返します。

**`rollbackOnError`**: リモートミューテーションでエラーが発生した場合、キャッシュをロールバックするかどうか。

## 現在のデータにもとづいたミューテート

現在のデータにもとづいて、データの一部を更新したい場合があります。
Expand Down
21 changes: 11 additions & 10 deletions pages/docs/mutation.ko.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# 뮤테이션

```js
mutate(key, data, options)
```

## Options

- `optimisticData`: 클라이언트 캐시를 즉시 업데이트하기 위한 데이터. 일반적으로 낙관적인 UI에서 사용됩니다.
- `revalidate`: 비동기 업데이트가 해소되면 캐시를 갱신합니다.
- `populateCache`: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.
- `rollbackOnError`: 원격 뮤테이션 에러 시 캐시를 롤백합니다.

## 갱신하기

`useSWRConfig()` hook으로부터 `mutate` 함수를 얻을 수 있으며, `mutate(key)`를 호출하여
Expand Down Expand Up @@ -68,16 +79,6 @@ function Profile () {

> **`updateFn`**은 원격 뮤테이션을 다루기 위한 promise 또는 비동기 함수여야 합니다. 업데이트한 데이터를 반환해야 합니다.

**사용 가능한 옵션**

**`optimisticData`**: 클라이언트 캐시를 즉시 업데이트하기 위한 데이터. 일반적으로 낙관적인 UI에서 사용됩니다.

**`revalidate`**: 비동기 업데이트가 해소되면 캐시를 갱신합니다.

**`populateCache`**: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.

**`rollbackOnError`**: 원격 뮤테이션 에러 시 캐시를 롤백합니다.

## 현재 데이터를 기반으로 뮤테이트

현재 데이터를 기반으로 데이터의 일부를 업데이트하려는 경우가 있습니다.
Expand Down
21 changes: 11 additions & 10 deletions pages/docs/mutation.pt-BR.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Mutação

```js
mutate(key, data, options)
```

## Opções

- `optimisticData`: dados para serem atualizados imediatamente no cache do cliente, comumente usado para UI otimista.
- `revalidate`: se o cache deve revalidar quando a atualização assíncrona resolve.
- `populateCache`: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.
- `rollbackOnError`: se o cache deve reverter se a mutação remota falhar.

## Revalidar

Você pode obter a função `mutate` do hook `useSWRConfig()`, e transmitir uma mensagem de revalidação global
Expand Down Expand Up @@ -67,16 +78,6 @@ function Profile () {

> **`updateFn`** deve ser uma promise ou uma função assíncrona para lidar com a mutação remota, e deve retornar os dados atualizados.

**Opções Disponíveis**

**`optimisticData`**: dados para serem atualizados imediatamente no cache do cliente, comumente usado para UI otimista.

**`revalidate`**: se o cache deve revalidar quando a atualização assíncrona resolve.

**`populateCache`**: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.

**`rollbackOnError`**: se o cache deve reverter se a mutação remota falhar.

## Mutação Baseada nos Dados Atuais

As vezes, você quer atualizar uma parte de seus dados baseado nos dados atuais.
Expand Down
21 changes: 11 additions & 10 deletions pages/docs/mutation.ru.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Мутация

```js
mutate(key, data, options)
```

## Опции

- `optimisticData`: данные для немедленного обновления кеша клиента, обычно используемые в оптимистичном UI.
- `revalidate`: должен ли кеш повторно проверяться после разрешения асинхронного обновления.
- `populateCache`: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.
- `rollbackOnError`: следует ли выполнять откат кеша в случае ошибок удаленной мутации.

## Ревалидация

Вы можете получить функцию `mutate` из хука `useSWRConfig()`, и передать сообщение о ревалидации глобально другим SWR хукам<sup>\*</sup>, используя тот же ключ, вызвав `mutate(key)`.
Expand Down Expand Up @@ -64,16 +75,6 @@ function Profile () {

> **`updateFn`** должена быть промисом или асинхронной функцией для обработки удаленной мутации, она должна возвращать обновленные данные.

**Доступные опции**

**`optimisticData`**: данные для немедленного обновления кеша клиента, обычно используемые в оптимистичном UI.

**`revalidate`**: должен ли кеш повторно проверяться после разрешения асинхронного обновления.

**`populateCache`**: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.

**`rollbackOnError`**: следует ли выполнять откат кеша в случае ошибок удаленной мутации.

## Мутировать на основе текущих данных

Иногда вы хотите обновить часть ваших данных на основе текущих данных.
Expand Down
17 changes: 7 additions & 10 deletions pages/docs/mutation.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 数据更改

## Options

- `optimisticData`:立即更新客户端缓存的数据,通常用于 optimistic UI。
- `revalidate`:一旦完成异步更新,缓存是否重新请求。
- `populateCache`: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.
- `rollbackOnError`:如果远程更新出错,是否进行缓存回滚。

## 重新验证

你可以使用 `useSWRConfig()` 所返回的 `mutate` 函数,来广播重新验证的消息给其他的 SWR hook<sup>*</sup>。使用同一个 key 调用 `mutate(key)` 即可。
Expand Down Expand Up @@ -63,16 +70,6 @@ function Profile () {
```
> **`updateFn`** 应该是一个 promise 或异步函数来处理远程更新,它应该返回更新后的数据。

**Available Options**

**`optimisticData`**:立即更新客户端缓存的数据,通常用于 optimistic UI。

**`revalidate`**:一旦完成异步更新,缓存是否重新请求。

**`populateCache`**: should the result of the remote mutation be written to the cache, or a function that receives new result and current result as arguments and returns the mutation result.

**`rollbackOnError`**:如果远程更新出错,是否进行缓存回滚。

## 根据当前数据更改

有时,你想基于当前数据更新部分你的数据。
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/options.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { data, error, isValidating, mutate } = useSWR(key, fetcher, options)
- `data`: data for the given key resolved by `fetcher` (or undefined if not loaded)
- `error`: error thrown by `fetcher` (or undefined)
- `isValidating`: if there's a request or revalidation loading
- `mutate(data?, shouldRevalidate?)`: function to mutate the cached data [(details)](/docs/mutation)
- `mutate(data?, options?)`: function to mutate the cached data [(details)](/docs/mutation)

## Options

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/options.es-ES.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { data, error, isValidating, mutate } = useSWR(key, fetcher, options)
- `data`: data de la key dada resueltos por el `fetcher` (o undefined si no está cargado)
- `error`: error lanzado por el `fetcher` (o undefined)
- `isValidating`: si hay una solicitud o carga de revalidación
- `mutate(data?, shouldRevalidate?`: función para mutar los datos en caché [(detalles)](/docs/mutation)
- `mutate(data?, options?`: función para mutar los datos en caché [(detalles)](/docs/mutation)

## Opciones

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/options.ja.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { data, error, isValidating, mutate } = useSWR(key, fetcher, options)
- `data`: `fetcher` によって解決された、指定されたキーのデータ(もしくは、ロードされていない場合は undefined)
- `error`: `fetcher` によって投げられたエラー (もしくは undefined)
- `isValidating`: リクエストまたは再検証の読み込みがある場合
- `mutate(data?, shouldRevalidate?)`: キャッシュされたデータを更新する関数 [( 詳細 )](/docs/mutation)
- `mutate(data?, options?)`: キャッシュされたデータを更新する関数 [( 詳細 )](/docs/mutation)

## オプション

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/options.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { data, error, isValidating, mutate } = useSWR(key, fetcher, options)
- `data`: `fetcher`가 이행한 주어진 키에 대한 데이터(로드되지 않았다면 undefined)
- `error`: `fetcher`가 던진 에러(또는 undefined)
- `isValidating`: 요청이나 갱신 로딩의 여부
- `mutate(data?, shouldRevalidate?)`: 캐시 된 데이터를 뮤테이트하기 위한 함수 [(상세내용)](/docs/mutation)
- `mutate(data?, options?)`: 캐시 된 데이터를 뮤테이트하기 위한 함수 [(상세내용)](/docs/mutation)

## 옵션

Expand Down
Loading