Spaces:
Sleeping
Sleeping
File size: 653 Bytes
b64de39 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /**
* useApp - Custom hook for consuming AppContext.
*
* Provides access to global application state and actions:
* - language, preferences, loading, error
* - setLanguage, toggleLanguage, setPreferences
* - setLoading, setError, clearError, resetState
*/
import { useContext } from "react";
import { AppContext } from "@context/AppContext";
/**
* @returns {Object} AppContext value.
* @throws {Error} If used outside of an AppProvider.
*/
export default function useApp() {
const context = useContext(AppContext);
if (context === null) {
throw new Error("useApp must be used within an <AppProvider>.");
}
return context;
}
|