optimize mobx store: prevent unnecessary rerender
This commit is contained in:
parent
234fe462da
commit
842820af54
@ -5,6 +5,7 @@ import {
|
||||
import actionsEffects from 'client/stores/CalculationStore/Effects/action';
|
||||
// import assignProperties from 'client/tools/assignProps';
|
||||
import { ICalculationStore } from 'core/types/stores';
|
||||
import { isEqual } from 'lodash';
|
||||
import { autorun, makeAutoObservable, reaction, when } from 'mobx';
|
||||
import CommonStore from '../CommonStore';
|
||||
import {
|
||||
@ -43,11 +44,12 @@ autorunEffects.map(autorunEffect =>
|
||||
|
||||
reactionEffects.map(reactionEffectBuilder => {
|
||||
const reactionEffect = reactionEffectBuilder(CalculationStore);
|
||||
return reaction(
|
||||
reactionEffect.expression,
|
||||
reactionEffect.effect,
|
||||
reactionEffect.options,
|
||||
);
|
||||
return reaction(reactionEffect.expression, reactionEffect.effect, {
|
||||
...reactionEffect.options,
|
||||
equals: (nextParams, prevParams) => {
|
||||
return isEqual(nextParams, prevParams);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
whenEffects.map(whenEffectBuilder => {
|
||||
|
||||
Reference in New Issue
Block a user