A reducer handles an action by sorting a copy of its list and returning a new state object every time, even when the resulting order is identical. Two of these dispatches fire in one handler. What re-render behavior should you expect, and why?
function reducer(state, action) {
switch (action.type) {
case 'sort':
return { ...state, items: [...state.items].sort() };
default:
return state;
}
}
// inside a handler:
dispatch({ type: 'sort' });
dispatch({ type: 'sort' });