Wouldn’t it be enough to simply compare it with PureComponent?
I think it is rare that the state reference changes but the actual value does not change
过去多啦不再A梦2017-07-05 10:40:52
I think the advantage of immutable is that it is immutable and the value will not be accidentally changed elsewhere. It can also be compared quickly without the need to check layer by layer.
欧阳克2017-07-05 10:40:52
I think immutable
does have benefits. Immutability and comparison of two objects can improve performance to a certain extent. But this is more suitable for complex data structures and frequent data operations.
For general scenarios, it only increases the complexity and file size. For example, get the object attributesconst obj = {a: 1, b: 2, c: 3}
Normal way:
const {a, b, c} = obj;
immutable:
const a = obj.get('a');
const b = obj.get('b');
const c = obj.get('c');
And if it is a complex scenario, we will use redux, because the data processing of redux itself is immutable, so immutable is not applicable.
给我你的怀抱2017-07-05 10:40:52
Strictly speaking, converting immutable data will also cause performance losses.
The API is very convenient for comparison and modification of very deep data
reducer.js
[actions.UPDATE_PROJECT_LIST_AFTER_DELETE]: (state, { data }) => {
let index = data.index
return state.updateIn(['dataList',index,'status'], () => 'Deleted')
}