import * as React from "react";
import {UserContext} from "../context/UserContext";

export function useUser() {
    const context = React.useContext(UserContext);

    if (!context) {
        throw new Error('useUser must be used within a UserProvider');
    }

    window.user = context;
    return context;
}