immer.js

Immer drafts, computed properties

给你一囗甜甜゛ 提交于 2019-12-24 11:43:53
问题 Im not sure why I'm getting Error: Immer drafts cannot have computed properties in my reducer code. I'm using redux-starter-kit which wraps all my reducer code with the Immer library. I'm not entirely sure what Immer is referring to with "computed property." Does it mean getters/setters? Because I'm not creating any getters or setters explicitly. Is the object spread operator doing it? Do getters/setters contaminate the state object somehow? Or is computed property in reference to computed

DeepCopy Object in JavaScript using immer

ぃ、小莉子 提交于 2019-12-10 13:51:59
问题 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" } produce(state, draft => {}) produce(state, draft => undefined) // Both return the original state: { hello: "world"} This is from the official immer README. Does this mean that passing an empty function to produce returns a deep copy of the original state or actually the original state? Thank you very