当我分派多个动作时,我的应用程序速度显着下降。
问题:
我的组件componentDidMount。
componentDidMount () {
let start = Date.now();
let timePassed;
this.props.action1();
timePassed = Date.now() - start;
console.log(timePassed); // 313 ms
this.props.action2();
timePassed = Date.now() - start;
console.log(timePassed); // 652 ms
this.props.action3();
timePassed = Date.now() - start;
console.log(timePassed); // 1038 ms
this.props.action4();
timePassed = Date.now() - start;
console.log(timePassed); // 1441 ms
this.props.action5();
timePassed = Date.now() - start;
console.log(timePassed); // 1832 ms
}
我的动作
export const action1 = () => ({
type: 'TYPE',
name: 'NAME',
});
我的减速器:
const actionReducer = (state, action) => {
const { name } = action;
return setIn(state, [name], {}); // Mutable lodash version of set.
};
编辑:我尝试进行生产构建,每次调度的时间降至0-2毫秒,但我仍然希望它在开发中能更快。