I have an action and reducer that updates a global counter. This action is fired on a rapid interval. The reducer returns a new copy of the state for each action. The reduce
If it is a performance issue due to redux, use react shouldComponentUpdate
method.
https://reactjs.org/docs/react-component.html#shouldcomponentupdate
Update: CombineReducers would make a difference. Try changing
return {
...state,
loop: action.payload,
}
to
state.loop = ...action.payload;
return state;
If you don't want to mutate the state, you should use combineReducer with loop as its own reducer. Since you weren't using combineReducers, I turned the state into the rootReducer. Its similar to what the redux author does with combineReducers (video) with the exception that the nextState was created within the combineReducer.