Questions tagged [immer]
8 questions
1
vote
0 answers
Typing the `set` method from Zustand store with Immer middleware while keeping autocomplete
I'm having trouble typing the set method from Zustand store while using Immer middleware. I do need to type it since some properties contain functions that will update the state, so they need the set function:
export const useStore =…

Vikms
- 11
- 2
0
votes
0 answers
When are harmony exports generated by Webpack?
I have an angular config that output that outputs among others :
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Immer: () => (/* binding */ Immer2),
/* harmony…

Matthieu Riegler
- 31,918
- 20
- 95
- 134
0
votes
1 answer
How to use readonly arrays with Immer + TypeScript? (version 8 regression)
Consider the following short code snippet.
Immer seems to have a problem with readonly arrays, which doesn't make sense to me, because your state should always be immutable, which is the whole point of using immer in the first place.
Before Immer…

James
- 1,394
- 2
- 21
- 31
0
votes
1 answer
Using react useImmerReducer is causing a side effect that duplicates the changed item in a deeply nested array
I'm trying to update an object in a deeply nested array with useImmerReducer on React.
For simplicity, the object looks like below
{
flags: ['green', 'blue'],
configs: [
{
baseTables: [
{
name:…

Wagner D'Amaral
- 227
- 1
- 2
- 9
0
votes
0 answers
Object dispatched to Redux store (with Immer) is frozen and is now readonly - React
Immer freezes the redux store to make the data immutable. As a result, I'm seeing the following issue:
I dispatch an object that (can be) rather large with other Objects nested in it to the redux store.
const object = {...all kinds of stuff in…

Illya B.
- 1
- 1
0
votes
0 answers
How to incrementally apply Immer patch(es) to a firestore doc?
I have an app that uses Immer for handling state, with patches/inverse patches being used and stored for undo+document history. I would like to use the patches generated by Immer's produce function to update a portion of a Firestore doc, but I…

elunomas
- 161
- 6
0
votes
1 answer
How do I sort a cached array in RTK Query?
I'm building an app with RTK Query where the user can drag and drop to reorder their 'shelves'. I want to optimistically update the shelf order but am confused about what I'm allowed to do to the proxy array Immer exposes.
I cloned it with .slice…
0
votes
1 answer
Vite module load order - calling a named import before default import evaluated
I am using immer for state immutability in a Vite React application. If you want to load the immer plugin for drafting Maps and Sets (as well as object and array literals) you need to call enableMapSet() before importing the immer default export.…

cefn
- 2,895
- 19
- 28