Skip to content

Commit ad43c89

Browse files
committed
Make 'immer' library (and 'use-immer') available
Immer makes immutable data structures easier to work with. - https://immerjs.github.io/immer/ Useful because there are places in React and React Query where you need to create a copy of an immutable object with some changes, and Immer can be much easier to write and read than the equivalent spread syntax. - updating state from useState, or using reducers (React) https://react.dev/learn/updating-objects-in-state#write-concise-update-logic-with-immer https://react.dev/learn/updating-arrays-in-state#write-concise-update-logic-with-immer https://react.dev/learn/extracting-state-logic-into-a-reducer#writing-concise-reducers-with-immer - updating a state cache after mutation to avoid re-fetching, or to show optimistic updates (React Query) https://tanstack.com/query/latest/docs/framework/react/guides/updates-from-mutation-responses#immutability https://tanstack.com/query/latest/docs/framework/react/guides/optimistic-updates#via-the-cache
1 parent c5928f5 commit ad43c89

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"chai-deep-equal-ignore-undefined": "^1.1.1",
1919
"classnames": "^2.3.1",
2020
"fuse.js": "^6.4.3",
21+
"immer": "^10.1.1",
2122
"immutable": "^3.8.2",
2223
"jquery": "^3.5.1",
2324
"jquery-ui": "1.12.1",
@@ -69,6 +70,7 @@
6970
"reflux-core": "^1.0.0",
7071
"select2": "3.5.2-browserify",
7172
"spark-md5": "^3.0.2",
73+
"use-immer": "^0.10.0",
7274
"wretch": "^2.9.0",
7375
"zxcvbn": "^4.4.2"
7476
},

0 commit comments

Comments
 (0)