Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactuseReducerSingle-choice MCQ

You want to add logging around every state transition without touching the reducer. A teammate wraps dispatch like below and passes loggingDispatch down. What is the main correctness problem with this approach?

const [state, dispatch] = useReducer(reducer, init); const loggingDispatch = (action) => { console.log('action', action, 'state', state); dispatch(action); };