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

make explicit the location of mutate #354

Merged
merged 4 commits into from
Sep 21, 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
25 changes: 24 additions & 1 deletion pages/docs/mutation.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ SWR provides the `mutate` and `useSWRMutation` APIs for mutating remote data and

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// Or you can use globalMutate directly
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const data = await mutate(key, data, options)
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```

### API
Expand Down
25 changes: 24 additions & 1 deletion pages/docs/mutation.es-ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ SWR provides the `mutate` and `useSWRMutation` APIs for mutating remote data and

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// Or you can use globalMutate directly
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const data = await mutate(key, data, options)
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```

### API
Expand Down
25 changes: 24 additions & 1 deletion pages/docs/mutation.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ SWR はリモートデータ及びキャッシュデータの更新のために

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// または globalMutate を直接使うこともできます
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const data = await mutate(key, data, options)
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```

### API
Expand Down
27 changes: 25 additions & 2 deletions pages/docs/mutation.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ SWR provides the `mutate` and `useSWRMutation` APIs for mutating remote data and

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// Or you can use globalMutate directly
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const data = await mutate(key, data, options)
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```

### API
Expand Down Expand Up @@ -128,7 +151,7 @@ function Profile () {

현재 데이터를 기반으로 데이터의 일부를 업데이트하려는 경우가 있습니다.

`mutate`를 사용해 현재 캐시 된 값을 받는(있으면 업데이트된 문서를 반환) 비동기 함수를 전달할 수 있습니다.
`mutate`를 사용해 현재 캐시 된 값을 받는(있으면 업데이트된 문서를 반환) 비동기 함수를 전달할 수 있습니다.

```jsx
mutate('/api/todos', async todos => {
Expand Down
25 changes: 24 additions & 1 deletion pages/docs/mutation.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ SWR provides the `mutate` and `useSWRMutation` APIs for mutating remote data and

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// Or you can use globalMutate directly
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const data = await mutate(key, data, options)
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```

### API
Expand Down
24 changes: 23 additions & 1 deletion pages/docs/mutation.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,32 @@ SWR provides the `mutate` and `useSWRMutation` APIs for mutating remote data and

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
const data = await mutate(key, data, options)
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// Or you can use globalMutate directly
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```
### API

#### Parameters
Expand Down
25 changes: 24 additions & 1 deletion pages/docs/mutation.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ SWR provides the `mutate` and `useSWRMutation` APIs for mutating remote data and

## mutate

There're 2 ways to use the `mutate` API to mutate the data, the global mutate API which can mutate any key and the bound mutate API which only can mutate the data of corresponding SWR hook.

#### Global Mutate

```js
import { mutate as globalMutate, useSWRConfig } from "swr"

function App() {
const { mutate } = useSWRConfig()
const data = mutate(key, data, options)

// Or you can use globalMutate directly
// await globalMutate(key, data, options)

}
```
#### Bound Mutate

[Bound Mutate](/docs/mutation#bound-mutate) is the short path to mutate the current key with data. Which `key` is bounded to the `key` passing to SWR, and receive the `data` as the first argument.


```js
const data = await mutate(key, data, options)
const { mutate } = useSWR(key, fetcher)

await mutate(data)
```

### API
Expand Down