Skip to content

Commit

Permalink
docs(useRefHistory): Suggest structuredClone as deep clone implementa…
Browse files Browse the repository at this point in the history
…tion (#1751)
  • Loading branch information
Holi0317 committed Jul 6, 2022
1 parent e93f742 commit 79e3257
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/core/useManualRefHistory/index.md
Expand Up @@ -52,7 +52,15 @@ commit()

To use a full featured or custom clone function, you can set up via the `dump` options.

For example, using [lodash's `cloneDeep`](https://lodash.com/docs/4.17.15#cloneDeep):
For example, using [structuredClone](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone):

```ts
import { cloneDeep } from 'lodash-es'

const refHistory = useManualRefHistory(target, { clone: structuredClone })
```

Or by using [lodash's `cloneDeep`](https://lodash.com/docs/4.17.15#cloneDeep):

```ts
import { cloneDeep } from 'lodash-es'
Expand Down
10 changes: 9 additions & 1 deletion packages/core/useRefHistory/index.md
Expand Up @@ -65,7 +65,15 @@ console.log(history.value)

`useRefHistory` only embeds the minimal clone function `x => JSON.parse(JSON.stringify(x))`. To use a full featured or custom clone function, you can set up via the `dump` options.

For example, using [lodash's `cloneDeep`](https://lodash.com/docs/4.17.15#cloneDeep):
For example, using [structuredClone](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone):

```ts
import { useRefHistory } from '@vueuse/core'

const refHistory = useRefHistory(target, { dump: structuredClone })
```

Or by using [lodash's `cloneDeep`](https://lodash.com/docs/4.17.15#cloneDeep):

```ts
import { cloneDeep } from 'lodash-es'
Expand Down

0 comments on commit 79e3257

Please sign in to comment.