Discuss the differences between React's useState and useReducer hooks.
Instruction: Compare and contrast useState and useReducer hooks in terms of functionality and use cases.
Context: This question is aimed at understanding the candidate's ability to choose between useState and useReducer based on the requirements of the application state management.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
useState gives a state value and a setter; useReducer gives state and a dispatch function that applies an action through a reducer. Both keep state for a component instance and schedule updates through React. Neither automatically shares it globally or makes updates faster.
Use useState when the update rules are small and clear...