Why should objects in Redux be immutable?

前端 未结 4 2021
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 06:25

Why should objects in Redux be immutable? I know that some frameworks such as Angular2 will use onPush and can take advantage of immutability to compare states of views for

4条回答
  •  臣服心动
    2020-12-05 07:05

    The main reason Redux is using immutability is that it doesn't have to traverse an object tree to check for the changes in every key value. Instead, it will only check the object's reference is changed or not in order to update DOM on state change.

提交回复
热议问题