import { useContext } from "react";
import { ProtocolContext, ProtocolContextType, ProtocolState } from "./ProtocolProvider";

export const useProtocolState = () => {
    const context : ProtocolContextType = useContext(ProtocolContext);

    if(!context){
        throw new Error("useProtocol must be used within a ProtocolProvider");
    }

    return [context[1], context[2]] as [ProtocolState, (state: ProtocolState) => void];
};