Mini Redux dùng Context + useReducer: store dùng chung cho toàn app mà không cần thư viện ngoài.
jsx
const StoreContext = createContext();
function StoreProvider({ children }) {
const [state, dispatch] = useReducer(reducer, initialState);
return (
<StoreContext.Provider value={{ state, dispatch }}>
{children}
</StoreContext.Provider>
);
}
const useStore = () => useContext(StoreContext);Phỏng vấn thường hỏi để test hiểu state management internals.