|
|
|
|
|
by acemarke
2373 days ago
|
|
There's a fantastic library called Immer [0] that uses ES6 Proxies to let you write "mutative" update logic that is tracked and turned into a safe immutable update. We recommend using Immer as the best way to write immutable logic with Redux [1], and our new Redux Toolkit package [2] automatically uses Immer internally to let you write reducers like this: const reducer = createReducer(initialState, {
updateItem(state, action) {
state.first.second[action.payload.id].fourth = action.payload.value
}
})
[0] https://immerjs.github.io/immer/[1] https://redux.js.org/style-guide/style-guide/#use-immer-for-... [2] https://redux-toolkit.js.org |
|