亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Does immutable work with react to improve performance?
學習ing
學習ing 2017-07-05 10:38:52
0
3
987

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

學習ing
學習ing

reply all(3)
過去多啦不再A夢

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.

學霸

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.

給我你的懷抱

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')
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template