Skip to content

Commit 77efcba

Browse files
committed
Fix page
1 parent 4406c2d commit 77efcba

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

src/content/learn/updating-objects-in-state.md

+3-30
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,7 @@ The `draft` provided by Immer is a special type of object, called a [Proxy](http
674674

675675
To try Immer:
676676

677-
1. Install the package:
678-
```bash
679-
npm install use-immer
680-
```
681-
677+
1. Run `npm install use-immer` to add Immer as a dependency
682678
2. Then replace `import { useState } from 'react'` with `import { useImmer } from 'use-immer'`
683679

684680
Here is the above example converted to Immer:
@@ -1287,24 +1283,6 @@ body { height: 280px; }
12871283
select { margin-bottom: 10px; }
12881284
```
12891285

1290-
```json package.json
1291-
{
1292-
"dependencies": {
1293-
"immer": "1.7.3",
1294-
"react": "latest",
1295-
"react-dom": "latest",
1296-
"react-scripts": "latest",
1297-
"use-immer": "0.5.1"
1298-
},
1299-
"scripts": {
1300-
"start": "react-scripts start",
1301-
"build": "react-scripts build",
1302-
"test": "react-scripts test --env=jsdom",
1303-
"eject": "react-scripts eject"
1304-
}
1305-
}
1306-
```
1307-
13081286
</Sandpack>
13091287

13101288
</Solution>
@@ -1333,13 +1311,8 @@ export default function Canvas() {
13331311
});
13341312

13351313
function handleMove(dx, dy) {
1336-
setShape({
1337-
...shape,
1338-
position: {
1339-
x: shape.position.x + dx,
1340-
y: shape.position.y + dy,
1341-
}
1342-
});
1314+
shape.position.x += dx;
1315+
shape.position.y += dy;
13431316
}
13441317

13451318
function handleColorChange(e) {

0 commit comments

Comments
 (0)