Skip to content

Commit

Permalink
docs(website): update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Sep 22, 2024
1 parent 1294a2e commit ac061f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions website/blog/releases/1.0/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,25 @@ const state = create(baseState, (draft) => {

```ts
// baseState type: { value: number }[]

// slower 6x than Mutative
const state = [
{ ...baseState[0], value: i },
...baseState.slice(1, baseState.length),
];

// slower 2.5x than Mutative
// const state = baseState.map((item, index) =>
// index === 0 ? { ...item, value: i } : item
// );

// same performance as Mutative
// const state = [...baseState];
// state[0] = { ...baseState[0], value: i };
```

> The actual difference depends on which spread operation syntax you use.
- Mutative

```ts
Expand Down
13 changes: 13 additions & 0 deletions website/docs/getting-started/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,25 @@ const state = create(baseState, (draft) => {

```ts
// baseState type: { value: number }[]

// slower 6x than Mutative
const state = [
{ ...baseState[0], value: i },
...baseState.slice(1, baseState.length),
];

// slower 2.5x than Mutative
// const state = baseState.map((item, index) =>
// index === 0 ? { ...item, value: i } : item
// );

// same performance as Mutative
// const state = [...baseState];
// state[0] = { ...baseState[0], value: i };
```

> The actual difference depends on which spread operation syntax you use.
- Mutative

```ts
Expand Down

0 comments on commit ac061f2

Please sign in to comment.