InterviewHubPRO
Section Overview
Q278

Question 278 of 445

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

62%
React & Modern Frontend (445 Qs)•Part 9: React Hooks Deep Dive (262 - 316)

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

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>
 );
}