tezvyn:

Explain useReducer and when to prefer it over useState

Source: react.devintermediate

Tests if you know useReducer centralizes complex state transitions better than scattered useState. Answer: define reducer/dispatch, then contrast with useState via interdependent fields or deep updates. Red flag: calling it only for global state or Redux.

Tests whether you can articulate when centralized reducer logic outperforms fragmented useState. A strong answer defines useReducer as a hook that accepts a pure reducer function and a dispatch method, then names a concrete scenario such as a multi-step form where fields depend on each other or a state machine with explicit transitions. Red flag: treating useReducer as merely a mini-Redux for global state or claiming it adds performance benefits by default.

Read the original → react.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Explain useReducer and when to prefer it over useState · Tezvyn