Skip to main content
InterviewHubPRO
Section Overview
Q278

Question 278 of 407

Part 9: React Hooks Deep Dive (262 - 316)

68%
React Core & Hooks (407 Qs)•Part 9: React Hooks Deep Dive (262 - 316)

Can you combine **useReducer** with **useContext**?

mid LevelCode ExampleHooks

Yes, it's common to combine useReducer with useContext to build a lightweight state management system similar to Redux:

js
const AppContext = React.createContext();

function AppProvider({ children }) {
 const [state, dispatch] = useReducer(reducer, initialState);
 return (
   <AppContext.Provider value={{ state, dispatch }}>
     {children}
   </AppContext.Provider>
 );
}