-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
精读《Immer.js》源码 #68
Comments
你好,我觉得 |
是不是因为 |
首先记住,所有对象初始值存在 基本上说到这就很清楚了, 下面的场景: produce(draft => console.log(draft.a.b))
produce(draft => {
draft.a = { b: 1 }
draft.a.b = 2
console.log(draft)
}) 第一行是直接 getter,全程没有修改过对象,那直接给你代理对象扔到 后面是先修改了 所以 Object.assign(state.copy, state.proxies) 在任何对象触发 |
大佬,我想明白了,是我一开始对 |
那 immer.js 的作用只是在改变状态上为重组状态提供了方便呗(不用扩展原状态和生成新引用),存储方式并没有改变,仍然是浅拷贝。 |
本周精读的源码是:https://github.com/mweststrate/immer
Immer 出来这么久了,为啥选它?因为最近它越来越火了。。我们当然不想知其然而不知所以然,所以,源码读起来吧~
The text was updated successfully, but these errors were encountered: