12 lines
433 B
TypeScript
12 lines
433 B
TypeScript
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];
|
|
}; |