immer.js Questions
4
I use @reduxjs/toolkit and my state contains: allSlides: ISlide[];
When I try to change anything in allSlides like ex.
setAllSlides(state, action: PayloadAction<ISlide[]>) {
state.allSlides ...
Ripplet asked 25/4, 2022 at 12:46
7
Solved
I have my reducer
const userAuthSlice = createSlice({
name: "userAuth",
initialState: {
token: '',
},
reducers: {
setToken: (state, action) => state.token = action.payload.test,
},
});
An...
Cartulary asked 22/3, 2020 at 23:22
2
Solved
EDIT: The solution is to return state after I replace it completely (return state = {...action.payload})! But why? I don't need to return it when I replace the fields individually.
I'm working wit...
Unnecessary asked 31/1, 2020 at 11:17
1
Here's a fix for the following vulnerability:
Critical Prototype Pollution in immer
Package immer
Patched in >=9.0.6
Dependency of react-scripts
Path react-scripts > react-dev-utils &...
Sanguinolent asked 4/11, 2021 at 16:57
2
Solved
In general, using a mutable object such as Map is strongly discouraged.
However, the magic of immer allows immutable objects to be manipulated as though they are mutable.
Specifically, immer suppor...
Jodoin asked 22/7, 2020 at 15:10
2
Solved
I am using immer to transform react/redux state. Can I also use immer to just deep copy an object without transforming it?
import produce, {nothing} from "immer"
const state = {
hello: "world"...
Cherriecherrita asked 5/3, 2019 at 9:8
1
Solved
import produce from "immer";
const initialState = {
isLoading: true,
error: "",
burgers: [],
};
export default function (state = initialState, action) {
switch (action.typ...
Spank asked 19/5, 2021 at 16:39
0
I'm trying to update a nested prop on one of my objects, which according to the docs should work exactly like that, I believe. Just the be clear the state has a list of lessons, each lesson has a l...
Blithe asked 7/5, 2021 at 11:36
2
Solved
I have some slices that use Sets in their state. I have this code:
import { configureStore } from '@reduxjs/toolkit';
import { enableMapSet } from 'immer';
import { reducers } from './reducers';
e...
Pander asked 5/1, 2021 at 12:50
3
Consider the following code, where line 2 fails with Property 'newProperty' does not exist on type 'WritableDraft<MyObject>'. TS7053
// data is of type MyObject which until now has only a pro...
Dieselelectric asked 27/2, 2021 at 14:49
4
Solved
I'm using immer in a react app to handle state changes. Let's say the state didn't change as I expected, so I'd want to debug it, but both console.log and debugger gives a Proxy object which doesn'...
0
When I have an object which has nested optional fields, like:
type FormState = {
aaa?: {
bbb?: {
ccc?: number
}
}
}
When I want to set value to aaa.bbb.ccc in typescript, I have to:
import pr...
Vershen asked 13/9, 2020 at 8:35
2
Solved
I don't know why even I have modified the draft, immer didn't provide me with a new state, but the old state instance with modified content.
import CartItem from "../../models/cart-item";...
0
when trying to console.log a piece of (an array) managed with @reduxjs/toolkit it is always either undefined or proxy.
when using import { original } from "immer"; and console.log(origina...
Angele asked 11/7, 2020 at 17:59
1
Solved
//I want my action to dispatch payload like
// {type:'update',payload:{'current.contact.mobile':'XXXXXXXXX'}}
//In reducer dynamically select the segment of state update needs to be applied t...
Faviolafavonian asked 27/12, 2019 at 15:7
3
Solved
I wonder if it is possible to update multiple properties of state with immer.js in one "call".
Say I have state:
export const initialState = {
isUserLogged: false,
menuIsClosed: false,
mobileM...
2
Looked around the web and can't find an example of using
import produce, {Draft} from "immer";
with the ngrx on()
the closest I can find is:
a non complete solution on:
https://github.com/immerjs...
Vacuum asked 10/7, 2019 at 4:44
0
I have this failing test using the produce method of immer.js:
it('should replace array reference in state', () => {
let state = {
someArray: [1],
};
const somArrayUpdate = [2, 3];
state...
1
© 2022 - 2024 — McMap. All rights reserved.